Created
May 26, 2011 13:58
-
-
Save cametan001/993201 to your computer and use it in GitHub Desktop.
おっさんにも解るwxPython
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import wx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import wx, commands, os.path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#インストールコマンド群 | |
installCommands=( | |
( #みくつべ♪インストールコマンド群 | |
"gksudo add-apt-repository ppa:khf03353/ppa-kaorin","gksudo apt-get update",'gksudo "apt-get -y install mikutube"' | |
), | |
( #みくかべ♪インストールコマンド群 | |
"gksudo add-apt-repository ppa:khf03353/ppa-kaorin","gksudo apt-get update",'gksudo "apt-get -y install mikukabe"' | |
), | |
( #audaciousスキンインストールコマンド群 | |
"gksudo apt-get update",'gksudo "apt-get -y install audacious"', | |
#gksudo に渡す際に"でコマンドをくくる必要があるので、文字列定義としては'を使っている | |
'gksudo "wget -P /usr/share/audacious/Skins/ http://mangareview.up.seesaa.net/image/mikumiku001.tar.gz"', | |
'gksudo "wget -P /usr/share/audacious/Skins/ http://mangareview.up.seesaa.net/image/mikumiku_00220.tar.gz"', | |
'gksudo "wget -P /usr/share/audacious/Skins/ http://mangareview.up.seesaa.net/image/mikumiku_003.tar.gz"', | |
'gksudo "tar xvzf /usr/share/audacious/Skins/mikumiku001.tar.gz -C /usr/share/audacious/Skins/"', | |
'gksudo "tar xvzf /usr/share/audacious/Skins/mikumiku_00220.tar.gz -C /usr/share/audacious/Skins/"', | |
'gksudo "tar xvzf /usr/share/audacious/Skins/mikumiku_003.tar.gz -C /usr/share/audacious/Skins/"', | |
'gksudo "rm -f /usr/share/audacious/Skins/mikumiku001.tar.gz"', | |
'gksudo "rm -f /usr/share/audacious/Skins/mikumiku_00220.tar.gz"', | |
'gksudo "rm -f /usr/share/audacious/Skins/mikumiku_003.tar.gz"', | |
) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# generated by wxGlade 0.6.3 on Thu May 26 19:39:49 2011 | |
import wx | |
# begin wxGlade: extracode | |
# end wxGlade | |
class MikunchApp(wx.Frame): | |
def __init__(self, *args, **kwds): | |
# begin wxGlade: MikunchApp.__init__ | |
kwds["style"] = wx.DEFAULT_FRAME_STYLE | |
wx.Frame.__init__(self, *args, **kwds) | |
self.label_1 = wx.StaticText(self, -1, u"みくんちゅ♪セットアップヘルパ") | |
self.chkMikutube = wx.CheckBox(self, -1, u"みくつべ♪のインストール") | |
self.chkMikukabe = wx.CheckBox(self, -1, u"みくかべ♪のインストール") | |
self.chkAudacious = wx.CheckBox(self, -1, u"audaciousのスキンをインストール") | |
self.cmbAudaciousConf = wx.ComboBox(self, -1, choices=[u"初音ミク001", u"初音ミク002", u"初音ミク003"], style=wx.CB_DROPDOWN|wx.CB_READONLY) | |
self.btCancel = wx.Button(self, wx.ID_CANCEL, "") | |
self.btOK = wx.Button(self, wx.ID_OK, "") | |
self.__set_properties() | |
self.__do_layout() | |
self.Bind(wx.EVT_BUTTON, self.on_btCancel_clicked, self.btCancel) | |
self.Bind(wx.EVT_BUTTON, self.on_btOK_clicked, self.btOK) | |
# end wxGlade | |
def __set_properties(self): | |
# begin wxGlade: MikunchApp.__set_properties | |
self.SetTitle(u"みくんちゅ♪セットアップヘルパ") | |
self.cmbAudaciousConf.SetSelection(-1) | |
# end wxGlade | |
def __do_layout(self): | |
# begin wxGlade: MikunchApp.__do_layout | |
sizer_1 = wx.BoxSizer(wx.VERTICAL) | |
sizer_2 = wx.BoxSizer(wx.VERTICAL) | |
sizer_4 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_3 = wx.BoxSizer(wx.HORIZONTAL) | |
sizer_2.Add(self.label_1, 0, wx.ALIGN_CENTER_HORIZONTAL, 0) | |
sizer_2.Add(self.chkMikutube, 0, 0, 0) | |
sizer_2.Add(self.chkMikukabe, 0, 0, 0) | |
sizer_3.Add(self.chkAudacious, 0, wx.ALIGN_CENTER_VERTICAL, 0) | |
sizer_3.Add(self.cmbAudaciousConf, 0, 0, 0) | |
sizer_2.Add(sizer_3, 1, wx.EXPAND, 0) | |
sizer_4.Add((240, 30), 0, 0, 0) | |
sizer_4.Add(self.btCancel, 0, 0, 0) | |
sizer_4.Add(self.btOK, 0, 0, 0) | |
sizer_2.Add(sizer_4, 1, wx.EXPAND, 0) | |
sizer_1.Add(sizer_2, 1, wx.EXPAND, 0) | |
self.SetSizer(sizer_1) | |
sizer_1.Fit(self) | |
self.Layout() | |
# end wxGlade | |
def on_btCancel_clicked(self, event): # wxGlade: MikunchApp.<event_handler> | |
print "Event handler `on_btCancel_clicked' not implemented!" | |
event.Skip() | |
def on_btOK_clicked(self, event): # wxGlade: MikunchApp.<event_handler> | |
print "Event handler `on_btOK_clicked' not implemented!" | |
event.Skip() | |
# end of class MikunchApp | |
if __name__ == "__main__": | |
app = wx.PySimpleApp(0) | |
wx.InitAllImageHandlers() | |
TopLevel = MikunchApp(None, -1, "") | |
app.SetTopWindow(TopLevel) | |
TopLevel.Show() | |
app.MainLoop() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def on_btCancel_clicked(self, event): # wxGlade: MikunchApp.<event_handler> | |
self.Close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def on_btCancel_clicked(self, event): # wxGlade: MikunchApp.<event_handler> | |
print "Event handler `on_btCancel_clicked' not implemented!" | |
event.Skip() | |
def on_btOK_clicked(self, event): # wxGlade: MikunchApp.<event_handler> | |
print "Event handler `on_btOK_clicked' not implemented!" | |
event.Skip() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def on_btOK_clicked(self, event): # wxGlade: MikunchApp.<event_handler> | |
print "Event handler `on_btOK_clicked' not implemented!" | |
event.Skip() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def on_btOK_clicked(self, event): # wxGlade: MikunchApp.<event_handler> | |
# 適用を行ってアプリケーションを終了する | |
# みくつべ♪インストールコマンドを実行 | |
[self.execCommand(cmd) for cmd in installCommands[0] if self.chkMikutube.GetValue()] | |
# みくかべ♪インストールコマンドを実行 | |
[self.execCommand(cmd) for cmd in installCommands[1] if self.chkMikukabe.GetValue()] | |
#ウィンドウを閉じてアプリケーションを終了する | |
self.Close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def on_btOK_clicked(self, event): # wxGlade: MikunchApp.<event_handler> | |
print "Event handler `on_btOK_clicked' not implemented!" | |
event.Skip() | |
#ウィンドウを閉じてアプリケーションを終了する | |
self.Close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def on_btOK_clicked(self,widget): | |
#適用を行ってアプリケーションを終了する | |
if self.chkMikutube.get_active() == True: | |
#みくつべ♪インストールコマンドを実行 | |
for cmd in installCommands[0]: | |
self.execCommand(cmd) | |
if self.chkMikukabe.get_active() == True: | |
#みくかべ♪インストールコマンドを実行 | |
for cmd in installCommands[1]: | |
self.execCommand(cmd) | |
if self.chkAudacious.get_active() == True: | |
#Audacious用のスキンインストールと適用 | |
for cmd in installCommands[2]: | |
self.execCommand(cmd) | |
#適用スキンのコンフィグ名を定義 | |
confName = ("mikumiku001","mikumiku_002 ","mikumiku_003") | |
#選択されているスキンの番号を取得 | |
sel = self.cmbAudaciousConf.get_active() | |
#コンフィグファイルのパスを生成 | |
configpath = os.path.expanduser("~") + "/.config/audacious/config" | |
#選択スキンをコンフィグファイルに設定 | |
self.editConfig("skin=", "skin=/usr/share/audacious/Skins/"+confName[sel], configpath) | |
#壊れているスキンも有効にする設定をTRUEに | |
self.editConfig('allow_broken_skins=',"allow_broken_skins=TRUE", configpath) | |
#ウィンドウを閉じてアプリケーションを終了する | |
gtk.main_quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment