def __init__(self,parent,id):
wx.Frame.__init__(self,parent,id,"Test App")
self.renderer = Renderer(self)
self.log = MyTextCtrl(self)
self.Canvas = MyCanvas(self)
sizer = wx.BoxSizer()
sizer.Add(self.Canvas,3,wx.EXPAND)
sizer.Add(self.log,1,wx.EXPAND)
self.SetSizer(sizer)
self.Bind(wx.EVT_CLOSE,self.OnExit)
self.Show(True)
python类EVT_CLOSE的实例源码
def show_decryption_dialog(self, event):
'''
@summary: Creates a dialog object to show the decryption dialog
'''
# If dialog open. Don't open another
if self.decryption_dialog:
return
# Create dialog object
self.decryption_dialog = EnterDecryptionKeyDialog(self)
# Set gauge size
self.decryption_dialog.DecryptionGauge.SetRange(100)
# Set encrypted file number
self.decryption_dialog.EncryptedFilesNumberLabel.SetLabelText(
self.GUI_DECRYPTION_DIALOG_LABEL_TEXT_FILE_COUNT[self.LANG] + str(
len(self.encrypted_files_list) - len(self.decrypted_files_list)
)
)
# Bind OK button to decryption process
self.decryption_dialog.Bind(wx.EVT_BUTTON, self.start_decryption_thread, self.decryption_dialog.OkCancelSizerOK)
# Bind close and cancel event to thread killer
self.decryption_dialog.Bind(wx.EVT_BUTTON, self.stop_decryption, self.decryption_dialog.OkCancelSizerCancel)
self.decryption_dialog.Bind(wx.EVT_CLOSE, self.stop_decryption)
self.decryption_dialog.Show()
def __init__(self, board):
"""Init the brand new instance"""
super(TeardropDialog, self).__init__(None)
self.board = board
self.SetTitle("Teardrops (v{0})".format(__version__))
self.rbx_action.Bind(wx.EVT_RADIOBOX, self.onAction)
self.Bind(wx.EVT_CLOSE, self.onCloseWindow)
self.but_cancel.Bind(wx.EVT_BUTTON, self.onCloseWindow)
self.but_ok.Bind(wx.EVT_BUTTON, self.onProcessAction)
def __init__(self, *args, **kw):
super(edit_gpio_dialog, self).__init__(*args, **kw)
self.InitUI()
self.SetSize((750, 300))
self.SetTitle("Device GPIO config")
self.Bind(wx.EVT_CLOSE, self.OnClose)
def __init__(self, *args, **kw):
super(cron_job_dialog, self).__init__(*args, **kw)
self.InitUI()
self.SetSize((750, 300))
self.SetTitle("Cron Job Editor")
self.Bind(wx.EVT_CLOSE, self.OnClose)
def __init__(self, *args, **kw):
super(file_download_dialog, self).__init__(*args, **kw)
self.InitUI()
self.SetSize((600, 300))
self.SetTitle("Download files from Pigrow")
self.Bind(wx.EVT_CLOSE, self.OnClose)
def __init__(self, *args, **kw):
super(upload_dialog, self).__init__(*args, **kw)
self.InitUI()
self.SetSize((600, 355))
self.SetTitle("upload files to Pigrow")
self.Bind(wx.EVT_CLOSE, self.OnClose)
def __init__(self, parent):
MainFrame.__init__(self, parent)
self.Bind(wx.EVT_CLOSE, self.OnClose)
MainApp.pi_link_pnl = pi_link_pnl(self)
self.view_pnl = view_pnl(self)
#
#Set the local file paths for this computer_username
self.set_local_options()
#
# loads all the pages at the start then hides them,
# maybe i should change this later but let's make it work first
MainApp.welcome_pannel = welcome_pnl(self)
MainApp.system_ctrl_pannel = system_ctrl_pnl(self)
MainApp.system_info_pannel = system_info_pnl(self)
MainApp.config_ctrl_pannel = config_ctrl_pnl(self)
MainApp.config_info_pannel = config_info_pnl(self)
MainApp.cron_list_pannel = cron_list_pnl(self)
MainApp.cron_info_pannel = cron_info_pnl(self)
MainApp.localfiles_ctrl_pannel = localfiles_ctrl_pnl(self)
MainApp.localfiles_info_pannel = localfiles_info_pnl(self)
#hide all except the welcome pannel
MainApp.system_ctrl_pannel.Hide()
MainApp.system_info_pannel.Hide()
MainApp.config_ctrl_pannel.Hide()
MainApp.config_info_pannel.Hide()
MainApp.cron_list_pannel.Hide()
MainApp.cron_info_pannel.Hide()
MainApp.localfiles_ctrl_pannel.Hide()
MainApp.localfiles_info_pannel.Hide()
def __init__(self):
wx.Frame.__init__(self, None, -1, 'My Frame')
self.hm = PyHook3.HookManager()
self.hm.MouseAllButtonsDown = self.OnMouseEvent
self.hm.KeyDown = self.OnKeyboardEvent
self.hm.HookMouse()
self.hm.HookKeyboard()
wx.EVT_CLOSE(self, self.OnClose)
def __init__(self, parent):
wx.Dialog.__init__(self, parent, title="Measure Scene", style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
self.SetSizeHints(640,480,-1,-1)
self.Bind(wx.EVT_CLOSE, self.OnExit)
self.panelvisual = self.GetParent()
self.nb = wx.Notebook(self)
self.nb.AddPage(MeasureLine(self.nb), "Line Scan")
self.nb.AddPage(MeasureAngle(self.nb), "Angle")
self.nb.AddPage(OrientXYZ(self.nb), "Orientation")
sizer = wx.BoxSizer()
sizer.Add(self.nb, 1, wx.EXPAND)
self.SetSizer(sizer)
self.Fit()
self.Layout()
self.Show()
def __init__(self, parent, title):
self.dirname=os.getcwd()
wx.Frame.__init__(self, parent, title=title, size=(1000,700))
self.SetSizeHints(1000,700,-1,-1)
self.CreateStatusBar()
filemenu= wx.Menu()
menuOpen = filemenu.Append(wx.ID_OPEN, "&Open"," Open saved state")
menuSave = filemenu.Append(wx.ID_SAVE, "&Save"," Save current state")
filemenu.InsertSeparator(2)
menuNew = filemenu.Append(wx.ID_NEW, "&New"," Create new session")
filemenu.InsertSeparator(4)
menuExit = filemenu.Append(wx.ID_EXIT,"E&xit"," Terminate the program")
viewmenu = wx.Menu()
vismenu = wx.Menu()
self.viewmenuundock = vismenu.Append(wx.ID_ANY,"&Undock","Undock the visualisation")
self.viewmenuundock.Enable(0)
self.viewmenudock = vismenu.Append(wx.ID_ANY,"&Dock","Dock the visualisation")
self.viewmenudock.Enable(0)
self.Bind(wx.EVT_MENU, self.OnUndock, self.viewmenuundock)
self.Bind(wx.EVT_MENU, self.OnDock, self.viewmenudock)
if IsNotWX4():
viewmenu.AppendMenu(wx.ID_ANY,"&Visualisation", vismenu)
else:
viewmenu.Append(wx.ID_ANY,"&Visualisation", vismenu)
self.visualdialog_docked = True
editmenu = wx.Menu()
self.menuCWD = editmenu.Append(wx.ID_ANY, "Current Working &Directory","Current Working Directory")
self.Bind(wx.EVT_MENU, self.OnCWD, self.menuCWD)
helpmenu= wx.Menu()
menuAbout= helpmenu.Append(wx.ID_ABOUT, "&About"," Information about Bonsu")
menuDoc= helpmenu.Append(wx.ID_HELP, "&Contents","Documentation")
menuBar = wx.MenuBar()
menuBar.Append(filemenu,"&File")
menuBar.Append(viewmenu,"&View")
menuBar.Append(editmenu,"&Edit")
menuBar.Append(helpmenu,"&Help")
self.SetMenuBar(menuBar)
self.Bind(wx.EVT_MENU, self.OnOpen, menuOpen)
self.Bind(wx.EVT_MENU, self.OnSave, menuSave)
self.Bind(wx.EVT_MENU, self.OnNew, menuNew)
self.Bind(wx.EVT_MENU, self.OnExit, menuExit)
self.Bind(wx.EVT_MENU, self.OnAbout, menuAbout)
self.Bind(wx.EVT_MENU, self.OnHelp, menuDoc)
self.Bind(wx.EVT_CLOSE, self.OnExit)
self.fontpointsize=wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT).GetPointSize()
self.font = wx.Font(self.fontpointsize, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
self.SetFont(self.font)
icon = wx.Icon(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'image', 'bonsu.ico'), wx.BITMAP_TYPE_ICO)
wx.Frame.SetIcon(self, icon)
self.nb = None
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.Fit()
self.Layout()
self.Show()
def __init__(self, title, pos, size):
self.threads = []
self.getsession = []
self.MAC=''
self.IP=''
wx.Frame.__init__(self, None, -1, title, pos, size)
menuFile = wx.Menu()
menuFile.Append(1, u"&??...",u"?????")
menuFile.Append(3,u"&????",u"?????IP")
menuFile.AppendSeparator()
menuFile.Append(2,u"&Bug Report",u"???????bug?")
menuBar = wx.MenuBar()
menuBar.Append(menuFile, u"&??")
self.SetMenuBar(menuBar)
self.Bind(wx.EVT_MENU, self.OnAbout,id=1)
self.Bind(wx.EVT_MENU,self.OnBugReport,id=2)
hosts = self.Bind(wx.EVT_MENU,self.OnSet,id=3)
self.CreateStatusBar()
self.SetStatusText(u"????")
panel = wx.Panel(self)
self.connect = wx.Button(panel,label=u"??",pos=(240, 60),size=(80, 50))
self.disconnect = wx.Button(panel,label=u"??",pos=(330,60),size=(80,50))
self.connect.Disable()
self.disconnect.Disable()
self.Bind(wx.EVT_BUTTON, self.OnDisconnect,self.disconnect)
self.Bind(wx.EVT_BUTTON,self.OnConnect,self.connect)
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
wx.StaticText(panel, -1, u"???:", pos=(28, 40))
self.username = wx.TextCtrl(panel, -1 ,pos=(80, 40))
self.username.SetInsertionPoint(0)
self.Bind(wx.EVT_TEXT,self.Onuser,self.username)
wx.StaticText(panel,-1,u"??:",pos=(242,40))
self.pwd = wx.TextCtrl(panel, -1,pos=(280,40),style=wx.TE_PASSWORD |wx.TE_PROCESS_ENTER)
self.Bind(wx.EVT_TEXT,self.Onpwd,self.pwd)
wx.CheckBox(panel, -1, u"????", (20, 80), (150, 20))
wx.CheckBox(panel, -1, u"????", (110, 80), (150, 20))
def __init__(self, parent):
wx.Dialog.__init__(self, parent, wx.ID_ANY, 'Facebook Login', size= (650,220))
self.panel = wx.Panel(self,wx.ID_ANY)
self.lbluser = wx.StaticText(self.panel, label='Username', pos=(20,20))
self.user = wx.TextCtrl(self.panel, value="", pos=(110,20), size=(500,-1))
self.lblpassword = wx.StaticText(self.panel, label='Password', pos=(20,60))
self.password = wx.TextCtrl(self.panel, value="", pos=(110,60), size=(500,-1), style=wx.TE_PASSWORD)
self.submitButton =wx.Button(self.panel, label='Submit', pos=(110,160))
self.closeButton = wx.Button(self.panel, label='Cancel', pos=(210,160))
self.submitButton.Bind(wx.EVT_BUTTON, self.SaveConnString)
self.closeButton.Bind(wx.EVT_BUTTON, self.OnQuit)
self.Bind(wx.EVT_CLOSE, self.OnQuit)
def __init__(self, parent, file):
super(WaveformPlot, self).__init__(parent=parent, title="pyjam Waveform Viewer",
style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
self.file = file
self.plot = plot.PlotCanvas(self)
self.plot.canvas.Bind(wx.EVT_LEFT_DOWN, self.lmb_down)
self.plot.canvas.Bind(wx.EVT_LEFT_UP, self.lmb_up)
self.plot.canvas.Bind(wx.EVT_MOTION, self.mouse_motion)
self.plot.EnableAxesValues = (True, False, False, False)
self.plot.EnableGrid = (True, False)
self.plot.AbsScale = (True, False)
self.plot.EnableAntiAliasing = True
self.panel = WaveformPanel(self)
sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer.Add(self.plot, 1, wx.EXPAND, 0)
sizer.Add(self.panel, 0, wx.EXPAND, 0)
self.SetSizerAndFit(sizer)
self.SetSize(800, self.GetSize()[1])
self.SetMinSize(self.GetSize())
self.player = wx.media.MediaCtrl(parent=self, style=wx.SIMPLE_BORDER)
self.volume = 25
self.selected = np.array([0.0, 0.0])
self.maximum = 0.0
self.minimum = 0.0
self.selection_drawn = False
self.resized = False
self.timer = wx.Timer(self)
self.Bind(wx.EVT_SIZE, self.on_size)
self.Bind(wx.EVT_TIMER, self.on_timer)
self.Bind(wx.EVT_IDLE, self.on_idle)
self.Bind(wx.EVT_CLOSE, self.on_exit)
self.load()
def InitUI(self):
self.panel = wx.Panel(self, wx.ID_ANY)
sizer = wx.BoxSizer(wx.VERTICAL)
self.html = help = wx.html.HtmlWindow(self.panel, -1, style=wx.NO_BORDER)
# http://wxpython-users.1045709.n5.nabble.com/Open-a-URL-with-the-default-browser-from-an-HtmlWindow-td2326349.html
# Bind LINK Click Event to own Function
help.Bind(wx.html.EVT_HTML_LINK_CLICKED, self.OnLinkClicked)
#import codecs
#file = codecs.open(self.help, "r", "utf-8")
try:
file = open(self.help, "r")
except IOError:
dlgmsg = u"File not found: \"{}\"".format(self.help)
dlg = wx.MessageDialog(None, dlgmsg, "WPKG-GP Client", wx.OK | wx.ICON_ERROR)
dlg.ShowModal()
dlg.Destroy()
self.Destroy()
else:
test = file.read().decode("utf-8")
html = markdown2.markdown(test, extras=["tables"])
html = '<body bgcolor="#f0f0f5">' + html
#print html
help.SetPage(html)
sizer.Add(help, 1, wx.EXPAND)
self.panel.SetSizerAndFit(sizer)
self.Bind(wx.EVT_CLOSE, self.OnClose)
def InitUI(self):
self.panel = wx.Panel(self, wx.ID_ANY)
self.textbox = wx.TextCtrl(self.panel, style=wx.TE_MULTILINE | wx.TE_READONLY)
self.textbox.SetValue(self.log)
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.textbox, 1, wx.ALL | wx.EXPAND, 5)
self.panel.SetSizerAndFit(self.sizer)
self.Center()
self.Bind(wx.EVT_CLOSE, self.OnClose)
def InitUI(self):
self.panel = wx.Panel(self, wx.ID_ANY)
self.textbox = wx.TextCtrl(self.panel, style=wx.TE_MULTILINE | wx.TE_READONLY)
self.textbox.SetValue(self.log)
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.textbox, 1, wx.ALL | wx.EXPAND, 5)
self.panel.SetSizerAndFit(self.sizer)
self.Center()
self.Bind(wx.EVT_CLOSE, self.OnClose)
def __init__(self, parent, fileOpen=None):
""" Constructor of the PLCOpenEditor class.
:param parent: The parent window.
:param fileOpen: The filepath to open if no controler defined (default: None).
"""
self.icon = wx.Icon(os.path.join(beremiz_dir, "images", "poe.ico"), wx.BITMAP_TYPE_ICO)
IDEFrame.__init__(self, parent)
result = None
# Open the filepath if defined
if fileOpen is not None:
fileOpen = DecodeFileSystemPath(fileOpen, False)
if os.path.isfile(fileOpen):
# Create a new controller
controler = PLCControler()
result = controler.OpenXMLFile(fileOpen)
self.Controler = controler
self.LibraryPanel.SetController(controler)
self.ProjectTree.Enable(True)
self.PouInstanceVariablesPanel.SetController(controler)
self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE)
# Define PLCOpenEditor icon
self.SetIcon(self.icon)
self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU)
if result is not None:
(num, line) = result
self.ShowErrorMessage(_("PLC syntax error at line {a1}:\n{a2}").format(a1=num, a2=line))
def _init_ctrls(self, prnt):
wx.Frame.__init__(self, id=ID_HTMLFRAME, name='HtmlFrame',
parent=prnt, pos=wx.Point(320, 231), size=wx.Size(853, 616),
style=wx.DEFAULT_FRAME_STYLE, title='')
self.SetIcon(prnt.icon)
self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
self.HtmlContent = UrlClickHtmlWindow(id=ID_HTMLFRAMEHTMLCONTENT,
name='HtmlContent', parent=self, pos=wx.Point(0, 0),
size=wx.Size(-1, -1), style=wx.html.HW_SCROLLBAR_AUTO | wx.html.HW_NO_SELECTION)
self.HtmlContent.Bind(HtmlWindowUrlClick, self.OnLinkClick)
def __init__(self, parent, title='Frame3D', manager=None):
wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = title, pos = wx.DefaultPosition, size = wx.Size( 800,600 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
self.SetSizeHints( wx.DefaultSize, wx.DefaultSize )
sizer = wx.BoxSizer( wx.VERTICAL )
root = os.path.abspath(os.path.dirname(__file__))
self.SetIcon(wx.Icon(os.path.join(root, 'imgs/logo.ico'), wx.BITMAP_TYPE_ICO))
self.viewer = canvas3d.Viewer3D( self , manager)
sizer.Add( self.viewer, 1, wx.EXPAND |wx.ALL, 0 )
self.Bind(wx.EVT_CLOSE, self.on_closing)
self.SetSizer( sizer )
self.Layout()
self.Centre( wx.BOTH )