【发布时间】:2016-04-06 21:11:25
【问题描述】:
我有 wxPython GUI 程序,它必须从用户那里获得输入才能运行。我想在主框架之前显示对话框,存储输入,关闭对话框,然后运行主程序。现在我正在使用 raw_input 代替。这是我的代码:
import wx
import wx.lib.iewin as iewin
import subprocess
class MyBrowser(wx.Frame):
def __init__(self, parent, id):
wx.Frame.__init__(self, parent, id,
style=wx.DEFAULT_FRAME_STYLE | wx.STAY_ON_TOP)
self.transparency = 255
sizer = wx.BoxSizer(wx.VERTICAL)
self.browser = iewin.IEHtmlWindow(self)
sizer.Add(self.browser, 1, wx.EXPAND, 10)
self.Bind(wx.EVT_CHAR_HOOK, self.onKey)
def SetTransparent(self, value):
self.transparency = value
wx.Frame.SetTransparent(self, value)
def GetTransparent(self):
return self.transparency
def decreaseTransparency(self, e):
self.SetTransparent(self.GetTransparent() - 10)
def increaseTransparency(self, e):
self.SetTransparent(self.GetTransparent() + 10)
def onKey(self, evt):
if evt.GetKeyCode() == wx.WXK_DOWN:
self.decreaseTransparency(self)
elif evt.GetKeyCode() == wx.WXK_UP:
self.increaseTransparency(self)
else:
evt.Skip()
def load(self,uri):
self.browser.Navigate(uri)
#starts livestreamer process
response = raw_input("Livestreamers name:\n")
livestreamer = "livestreamer twitch.tv/"
host = subprocess.Popen(['livestreamer', 'twitch.tv/'+response, 'best'], stdout=subprocess.PIPE)
if __name__ == '__main__':
app = wx.App()
dialog = MyBrowser(None, -1)
dialog.browser.Navigate("https://www.twitch.tv/" + response+ "/chat?popout=")
dialog.Show()
app.MainLoop()
host.communicate()[0]
这就是我的想法: dialog example
【问题讨论】:
标签: python python-2.7 wxpython