我们从Python开源项目中,提取了以下14个代码示例,用于说明如何使用wx.Gauge()。
def _upload_started(self): """Update the display when the upload is started. This method will add the progress bar to the display when the upload started topic is recieved. """ logging.info("Upload started for sample {}".format(self._sample.get_id())) pub.unsubscribe(self._upload_started, self._sample.upload_started_topic) self.Freeze() self._status_label.Destroy() self._progress = wx.Gauge(self, range=100, size=(100, 20)) self._sizer.Add(self._progress) self.Layout() self.Thaw() self._timer.Start(1000)
def _upload_started(self): """Update the display when the upload is started. This method will add the progress bar and progress text to the display when the run.upload_started_topic is received. """ logging.info("Upload started for {} with max size {}".format(self._run.upload_started_topic, self._progress_max)) pub.unsubscribe(self._upload_started, self._run.upload_started_topic) self.Freeze() self._progress = wx.Gauge(self, id=wx.ID_ANY, range=100, size=(250, 20)) self._progress_text = wx.StaticText(self, label=" 0%") progress_sizer = wx.BoxSizer(wx.HORIZONTAL) progress_sizer.Add(self._progress, proportion=1) progress_sizer.Add(self._progress_text, proportion=0) self._sizer.Insert(0, progress_sizer, flag=wx.EXPAND | wx.LEFT | wx.RIGHT, border=5) self.Layout() # Update our parent sizer so that samples don't get hidden self.GetParent().Layout() self.Thaw() self._timer.Start(1000)
def __init__( self, parent ): wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = 'ImagePy', size = wx.Size(-1,-1), pos = wx.DefaultPosition, style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL ) logopath = os.path.join(root_dir, 'data/logo.ico') #self.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_3DLIGHT ) ) self.SetIcon(wx.Icon(logopath, wx.BITMAP_TYPE_ICO)) self.SetSizeHints( wx.Size( 600,-1 ), wx.DefaultSize ) IPy.curapp = self # Todo:Fixed absolute/relative path! # print("menuspath:{}".format( os.path.join(root_dir,"menus"))) # print("toolspath:{}".format(os.path.join(root_dir,"tools")) # menuspath = os.path.join(root_dir, "menus") # toolspath = os.path.join(root_dir,"tools") self.menubar = pluginloader.buildMenuBarByPath(self, 'menus') self.SetMenuBar( self.menubar ) self.shortcut = pluginloader.buildShortcut(self) self.SetAcceleratorTable(self.shortcut) sizer = wx.BoxSizer(wx.VERTICAL) self.toolbar = toolsloader.build_tools(self, 'tools') #self.toolbar.Realize() #sizertool.Add(self.toolbar, 1, 0, 5 ) #sizertool.Add(self.morebar, 0, 0, 5) sizer.Add(self.toolbar, 0, wx.EXPAND, 5 ) #sizer.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 ) self.line_color = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) #self.line_color.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_HIGHLIGHT ) ) sizer.AddStretchSpacer(prop=1) sizer.Add(self.line_color, 0, wx.EXPAND |wx.ALL, 0 ) stapanel = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL ) sizersta = wx.BoxSizer( wx.HORIZONTAL ) self.txt_info = wx.StaticText( stapanel, wx.ID_ANY, "ImagePy v0.2", wx.DefaultPosition, wx.DefaultSize, 0 ) self.txt_info.Wrap( -1 ) #self.txt_info.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_INFOBK ) ) sizersta.Add( self.txt_info, 1, wx.ALIGN_BOTTOM|wx.BOTTOM|wx.LEFT|wx.RIGHT, 2 ) self.pro_bar = wx.Gauge( stapanel, wx.ID_ANY, 100, wx.DefaultPosition, wx.Size( 100,15 ), wx.GA_HORIZONTAL ) sizersta.Add( self.pro_bar, 0, wx.ALIGN_BOTTOM|wx.BOTTOM|wx.LEFT|wx.RIGHT, 2 ) stapanel.SetSizer(sizersta) stapanel.SetDropTarget(FileDrop()) sizer.Add(stapanel, 0, wx.EXPAND, 5 ) self.SetSizer( sizer ) self.Centre( wx.BOTH ) self.Layout() self.Fit() self.update = False self.Bind(wx.EVT_CLOSE, self.on_close) thread = threading.Thread(None, self.hold, ()) thread.setDaemon(True) thread.start()
def __init__(self, *args, **kwds): # begin wxGlade: update_win.__init__ kwds["style"] = wx.DEFAULT_DIALOG_STYLE wx.Dialog.__init__(self, *args, **kwds) self.label_installed_version = wx.StaticText(self, wx.ID_ANY, ("Installed Version:")) self.label_latest_version = wx.StaticText(self, wx.ID_ANY, ("Latest Version")) self.label_is_update = wx.StaticText(self, wx.ID_ANY, ("If Update available")) self.progress_bar = wx.Gauge(self, wx.ID_ANY, range=100) self.animation_panel = wx.Panel(self, wx.ID_ANY) self.label_status = wx.StaticText(self, wx.ID_ANY, ("")) self.button_close = wx.Button(self, wx.ID_ANY, ("Cancel")) self.button_install = wx.Button(self, wx.ID_ANY, ("Check for Update")) self.__set_properties() self.__do_layout() self.Bind(wx.EVT_BUTTON, self.on_cancel, self.button_close) self.Bind(wx.EVT_BUTTON, self.on_install, self.button_install) self.Bind(wx.EVT_CLOSE, self.on_close) self.animation_panel.gif = None # create a pubsub receiver Publisher().subscribe(self.update, "update") Publisher().subscribe(self.error_report, "error_report") Publisher().subscribe(self.update_progress_bar, "progress_bar") Publisher().subscribe(self.get_versions, "update_versions") Publisher().subscribe(self.is_update, "is_update") Publisher().subscribe(self.play_animation, "play_animation") Publisher().subscribe(self.stop_animation, "stop_animation") Publisher().subscribe(self.updation_successful, "updation_successful") #self.play_animation('') #wx.FutureCall(10, self.start_thread) # end wxGlade
def __init__(self, parent): wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=u"Background Task", pos=wx.DefaultPosition, size=wx.Size(500, 300), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL) self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize) sizer = wx.BoxSizer(wx.VERTICAL) gb_sizer = wx.GridBagSizer(5, 5) gb_sizer.SetFlexibleDirection(wx.BOTH) gb_sizer.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED) self.gauge = wx.Gauge(self, wx.ID_ANY, 10 ** 3, wx.DefaultPosition, wx.DefaultSize, wx.GA_HORIZONTAL) self.gauge.SetValue(0) gb_sizer.Add(self.gauge, wx.GBPosition(0, 0), wx.GBSpan(1, 1), wx.EXPAND, 0) self.button = wx.Button(self, wx.ID_ANY, u"Run", wx.DefaultPosition, wx.DefaultSize, 0) gb_sizer.Add(self.button, wx.GBPosition(1, 0), wx.GBSpan(1, 1), wx.EXPAND, 0) gb_sizer.AddGrowableCol(0) sizer.Add(gb_sizer, 1, wx.EXPAND | wx.ALL, 5) self.SetSizer(sizer) self.Layout() self.Centre(wx.BOTH) # Connect Events self.button.Bind(wx.EVT_BUTTON, self.on_run) self.model = WatchableDict() self.model["complete"] = 0 pywatch.wx.ValueWatcher(self.gauge, self.model, "complete") # Virtual event handlers, overide them in your derived class
def __init__(self): """Constructor""" wx.Dialog.__init__(self, None, title="Progress") self.count = 0 self.progress = wx.Gauge(self, range=20) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.progress, 0, wx.EXPAND) self.SetSizer(sizer) # create a pubsub receiver pub.subscribe(self.updateProgress, "update")
def __init__(self): """Constructor""" wx.Dialog.__init__(self, None, title="Progress") self.count = 0 self.progress = wx.Gauge(self, range=20) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.progress, 0, wx.EXPAND) self.SetSizer(sizer) # create a pubsub listener Publisher().subscribe(self.updateProgress, "update")
def InitUI(self): self.panel = wx.Panel(self, wx.ID_ANY) # Info Text infotext = _(u'Close all open Applications, it is possible that programs will be closed without a warning ' u'and system could reboot without further confirmation.') infobox = wx.StaticBox(self.panel, -1, _(u'Attention')) infoboxbsizer = wx.StaticBoxSizer(infobox, wx.VERTICAL) info = wx.StaticText(self.panel, label=infotext) info.Wrap(380) infoboxbsizer.Add(info, 0) self.gauge = wx.Gauge(self.panel, size=(24, 26)) self.update_label = wx.StaticText(self.panel, label=_(u'Current Progress:')) self.update_box = wx.TextCtrl(self.panel, style=wx.TE_READONLY) self.update_box.SetBackgroundColour(wx.WHITE) self.chk_shutdown = wx.CheckBox(self.panel, size=(160,20), label=_(u"Shutdown after update")) self.logButton = wx.Button(self.panel, size=(54,26), label="LOG") self.logButton.SetToolTip(wx.ToolTip(_(u'Open WPKG Log'))) self.logButton.SetBitmap(img.get('log')) self.startButton = wx.Button(self.panel, label=_(u"Update")) self.abortButton = wx.Button(self.panel, label=_(u"Cancel")) self.logButton.Disable() self.abortButton.Disable() self.line = wx.StaticLine(self.panel, -1, size=(2,2), style=wx.LI_HORIZONTAL) self.startButton.Bind(wx.EVT_BUTTON, self.OnStartButton) self.abortButton.Bind(wx.EVT_BUTTON, self.OnAbortButton) self.logButton.Bind(wx.EVT_BUTTON, self.OnLogButton) self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer2 = wx.BoxSizer(wx.HORIZONTAL) self.sizer.Add(infoboxbsizer, 0, wx.ALL | wx.EXPAND, 5) self.sizer.Add(self.gauge, 0, wx.ALL | wx.EXPAND, 5) self.sizer.Add(self.update_label, 0, wx.ALL | wx.EXPAND, 5) self.sizer.Add(self.update_box, 0, wx.ALL | wx.EXPAND, 5) self.sizer.Add(self.line, 0, wx.ALL | wx.EXPAND, 5) self.sizer.Add(self.chk_shutdown, 0, wx.LEFT | wx.EXPAND, 7) self.sizer2.Add(self.logButton, 0) self.sizer2.AddStretchSpacer() self.sizer2.Add(self.startButton, 0)#, wx.RIGHT, 2) self.sizer2.Add(self.abortButton, 0) self.sizer.Add(self.sizer2, 0, wx.ALL | wx.EXPAND, 5) self.panel.SetSizerAndFit(self.sizer) self.Center()
def __init__(self, *args, **kwds): # begin wxGlade: sampoorna_win.__init__ kwds["style"] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) self.notebook_1 = wx.Notebook(self, wx.ID_ANY, style=0) self.login_pane = wx.Panel(self.notebook_1, wx.ID_ANY) self.panel_login = wx.Panel(self.login_pane, wx.ID_ANY) self.label_1 = wx.StaticText(self.panel_login, wx.ID_ANY, _("Warning: Always backup your database before you proceed to avoid potential data loss !!!")) self.label_2 = wx.StaticText(self.panel_login, wx.ID_ANY, _("This software does not save Sampoorna credentials. It is used for one time login")) self.panel_1 = wx.Panel(self.panel_login, wx.ID_ANY, style=wx.SUNKEN_BORDER | wx.RAISED_BORDER | wx.TAB_TRAVERSAL) self.label_3 = wx.StaticText(self.panel_1, wx.ID_ANY, _("Sampoorna Username")) self.text_ctrl_user = wx.TextCtrl(self.panel_1, wx.ID_ANY, "", style=wx.TE_PROCESS_ENTER | wx.NO_BORDER) self.label_4 = wx.StaticText(self.panel_1, wx.ID_ANY, _("Sampoorna Password")) self.text_ctrl_passw = wx.TextCtrl(self.panel_1, wx.ID_ANY, "", style=wx.TE_PROCESS_ENTER | wx.TE_PASSWORD | wx.NO_BORDER) self.button_next = wx.Button(self.panel_login, wx.ID_ANY, _("Next >>")) self.standard_pane = wx.Panel(self.notebook_1, wx.ID_ANY) self.panel_3 = wx.Panel(self.standard_pane, wx.ID_ANY, style=wx.SUNKEN_BORDER | wx.RAISED_BORDER | wx.STATIC_BORDER | wx.TAB_TRAVERSAL) self.checkbox_8 = wx.CheckBox(self.panel_3, wx.ID_ANY, _("8 Standard")) self.checkbox_9 = wx.CheckBox(self.panel_3, wx.ID_ANY, _("9 Standard")) self.checkbox_10 = wx.CheckBox(self.panel_3, wx.ID_ANY, _("10 Standard")) self.button_previous = wx.Button(self.standard_pane, wx.ID_ANY, _("<<Previous")) self.button_proceed = wx.Button(self.standard_pane, wx.ID_ANY, _("Proceed >>")) self.report_pane = wx.Panel(self.notebook_1, wx.ID_ANY) self.panel_2 = wx.Panel(self.report_pane, wx.ID_ANY) self.label_7 = wx.StaticText(self.panel_2, wx.ID_ANY, _("Progress")) self.progresss_total = wx.Gauge(self.panel_2, wx.ID_ANY, range=100) self.progress_each = wx.Gauge(self.panel_2, wx.ID_ANY, range=100) self.label_satus = wx.StaticText(self.panel_2, wx.ID_ANY, _("Status")) self.list_ctrl_1 = wx.ListCtrl(self.panel_2, wx.ID_ANY, style=wx.LC_REPORT | wx.LC_ALIGN_LEFT | wx.SUNKEN_BORDER | wx.NO_BORDER) self.button_finished = wx.Button(self.panel_2, wx.ID_ANY, _("Finished")) self.__set_properties() self.__do_layout() self.Bind(wx.EVT_TEXT, self.on_user_pass_text, self.text_ctrl_passw) self.Bind(wx.EVT_TEXT, self.on_user_pass_text, self.text_ctrl_user) self.Bind(wx.EVT_BUTTON, self.on_next, self.button_next) self.Bind(wx.EVT_CHECKBOX, self.on_check, self.checkbox_8) self.Bind(wx.EVT_CHECKBOX, self.on_check, self.checkbox_9) self.Bind(wx.EVT_CHECKBOX, self.on_check, self.checkbox_10) self.Bind(wx.EVT_BUTTON, self.on_previous, self.button_previous) self.Bind(wx.EVT_BUTTON, self.on_proceed, self.button_proceed) self.Bind(wx.EVT_BUTTON, self.on_finished, self.button_finished) # create a pubsub receiver Publisher().subscribe(self.updateDisplay, "update") # end wxGlade
def __init__(self, *args, **kwds): # begin wxGlade: sampoorna_win.__init__ kwds["style"] = wx.DEFAULT_FRAME_STYLE wx.Dialog.__init__(self, *args, **kwds) self.notebook_1 = wx.Notebook(self, wx.ID_ANY, style=0) self.login_pane = wx.Panel(self.notebook_1, wx.ID_ANY) self.panel_login = wx.Panel(self.login_pane, wx.ID_ANY) self.label_1 = wx.StaticText(self.panel_login, wx.ID_ANY, ("Warning: Always backup your database before you proceed to avoid potential data loss !!!")) self.label_2 = wx.StaticText(self.panel_login, wx.ID_ANY, ("This software does not save Sampoorna credentials. It is used for one time login")) self.panel_1 = wx.Panel(self.panel_login, wx.ID_ANY, style=wx.SUNKEN_BORDER | wx.RAISED_BORDER | wx.TAB_TRAVERSAL) self.label_3 = wx.StaticText(self.panel_1, wx.ID_ANY, ("Sampoorna Username")) self.text_ctrl_user = wx.TextCtrl(self.panel_1, wx.ID_ANY, "", style=wx.TE_PROCESS_ENTER | wx.NO_BORDER) self.label_4 = wx.StaticText(self.panel_1, wx.ID_ANY, ("Sampoorna Password")) self.text_ctrl_passw = wx.TextCtrl(self.panel_1, wx.ID_ANY, "", style=wx.TE_PROCESS_ENTER | wx.TE_PASSWORD | wx.NO_BORDER) self.button_next = wx.Button(self.panel_login, wx.ID_ANY, ("Next >>")) self.standard_pane = wx.Panel(self.notebook_1, wx.ID_ANY) self.panel_3 = wx.Panel(self.standard_pane, wx.ID_ANY, style=wx.SUNKEN_BORDER | wx.RAISED_BORDER | wx.STATIC_BORDER | wx.TAB_TRAVERSAL) self.checkbox_8 = wx.CheckBox(self.panel_3, wx.ID_ANY, ("8 Standard")) self.checkbox_9 = wx.CheckBox(self.panel_3, wx.ID_ANY, ("9 Standard")) self.checkbox_10 = wx.CheckBox(self.panel_3, wx.ID_ANY, ("10 Standard")) self.button_previous = wx.Button(self.standard_pane, wx.ID_ANY, ("<<Previous")) self.button_proceed = wx.Button(self.standard_pane, wx.ID_ANY, ("Proceed >>")) self.report_pane = wx.Panel(self.notebook_1, wx.ID_ANY) self.panel_2 = wx.Panel(self.report_pane, wx.ID_ANY) self.label_7 = wx.StaticText(self.panel_2, wx.ID_ANY, ("Progress")) self.progresss_total = wx.Gauge(self.panel_2, wx.ID_ANY, range=100) self.label_progress_perc = wx.StaticText(self.panel_2, wx.ID_ANY, ("")) self.label_satus = wx.StaticText(self.panel_2, wx.ID_ANY, ("Status")) #self.list_ctrl_1 = wx.ListCtrl(self.panel_2, wx.ID_ANY, style=wx.LC_REPORT | wx.LC_ALIGN_LEFT | wx.SUNKEN_BORDER | wx.NO_BORDER) self.text_ctrl_report = wx.TextCtrl(self.panel_2, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_READONLY | wx.HSCROLL | wx.NO_BORDER) self.button_finished = wx.Button(self.panel_2, wx.ID_ANY, ("Abort")) self.__set_properties() self.__do_layout() self.Bind(wx.EVT_TEXT, self.on_user_pass_text, self.text_ctrl_passw) self.Bind(wx.EVT_TEXT, self.on_user_pass_text, self.text_ctrl_user) self.Bind(wx.EVT_BUTTON, self.on_next, self.button_next) self.Bind(wx.EVT_CHECKBOX, self.on_check, self.checkbox_8) self.Bind(wx.EVT_CHECKBOX, self.on_check, self.checkbox_9) self.Bind(wx.EVT_CHECKBOX, self.on_check, self.checkbox_10) self.Bind(wx.EVT_BUTTON, self.on_previous, self.button_previous) self.Bind(wx.EVT_BUTTON, self.on_proceed, self.button_proceed) self.Bind(wx.EVT_BUTTON, self.on_finished, self.button_finished) # create a pubsub receiver Publisher().subscribe(self.update_display, "update") Publisher().subscribe(self.final_report, "report") Publisher().subscribe(self.update_progress_bar, "progress_bar") Publisher().subscribe(self.update_current_class, "change_class") # end wxGlade
def __init__(self, *args, **kwds): # begin wxGlade: sampoorna_win.__init__ kwds["style"] = wx.CAPTION | wx.CLOSE_BOX | wx.MAXIMIZE | wx.MAXIMIZE_BOX | wx.SYSTEM_MENU | wx.RESIZE_BORDER | wx.CLIP_CHILDREN wx.Dialog.__init__(self, *args, **kwds) self.notebook_1 = wx.Notebook(self, wx.ID_ANY, style=0) self.login_pane = wx.Panel(self.notebook_1, wx.ID_ANY) self.panel_login = wx.Panel(self.login_pane, wx.ID_ANY) self.label_1 = wx.StaticText(self.panel_login, wx.ID_ANY, ("Warning: Always backup your database before you proceed to avoid potential data loss !!!")) self.label_2 = wx.StaticText(self.panel_login, wx.ID_ANY, ("This software does not save Sampoorna username or password. It is used for one time login")) self.panel_1 = wx.Panel(self.panel_login, wx.ID_ANY, style=wx.SUNKEN_BORDER | wx.RAISED_BORDER | wx.TAB_TRAVERSAL) self.label_3 = wx.StaticText(self.panel_1, wx.ID_ANY, ("Sampoorna Username")) self.text_ctrl_user = wx.TextCtrl(self.panel_1, wx.ID_ANY, "", style=wx.TE_PROCESS_ENTER | wx.NO_BORDER) self.label_4 = wx.StaticText(self.panel_1, wx.ID_ANY, ("Sampoorna Password")) self.text_ctrl_passw = wx.TextCtrl(self.panel_1, wx.ID_ANY, "", style=wx.TE_PROCESS_ENTER | wx.TE_PASSWORD | wx.NO_BORDER) self.button_next = wx.Button(self.panel_login, wx.ID_ANY, ("Next >>")) self.standard_pane = wx.Panel(self.notebook_1, wx.ID_ANY) self.panel_3 = wx.Panel(self.standard_pane, wx.ID_ANY, style=wx.SUNKEN_BORDER | wx.RAISED_BORDER | wx.STATIC_BORDER | wx.TAB_TRAVERSAL) self.checkbox_8 = wx.CheckBox(self.panel_3, wx.ID_ANY, ("8 Standard")) self.checkbox_9 = wx.CheckBox(self.panel_3, wx.ID_ANY, ("9 Standard")) self.checkbox_10 = wx.CheckBox(self.panel_3, wx.ID_ANY, ("10 Standard")) self.button_previous = wx.Button(self.standard_pane, wx.ID_ANY, ("<<Previous")) self.button_proceed = wx.Button(self.standard_pane, wx.ID_ANY, ("Proceed >>")) self.report_pane = wx.Panel(self.notebook_1, wx.ID_ANY) self.panel_2 = wx.Panel(self.report_pane, wx.ID_ANY) self.label_7 = wx.StaticText(self.panel_2, wx.ID_ANY, ("Progress")) self.progresss_total = wx.Gauge(self.panel_2, wx.ID_ANY, range=100) self.progress_each =wx.StaticText(self.panel_2, wx.ID_ANY)# wx.TextCtrl(self.panel_2, wx.ID_ANY, "", style=wx.TE_READONLY) self.label_satus = wx.StaticText(self.panel_2, wx.ID_ANY, ("Status")) self.text_ctrl_report = wx.TextCtrl(self.panel_2, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_READONLY | wx.HSCROLL | wx.NO_BORDER) self.button_finished = wx.Button(self.panel_2, wx.ID_ANY, ("Abort")) self.__set_properties() self.__do_layout() self.Bind(wx.EVT_TEXT, self.on_user_pass_text, self.text_ctrl_passw) self.Bind(wx.EVT_TEXT, self.on_user_pass_text, self.text_ctrl_user) self.Bind(wx.EVT_BUTTON, self.on_next, self.button_next) self.Bind(wx.EVT_CHECKBOX, self.on_check, self.checkbox_8) self.Bind(wx.EVT_CHECKBOX, self.on_check, self.checkbox_9) self.Bind(wx.EVT_CHECKBOX, self.on_check, self.checkbox_10) self.Bind(wx.EVT_BUTTON, self.on_previous, self.button_previous) self.Bind(wx.EVT_BUTTON, self.on_proceed, self.button_proceed) self.Bind(wx.EVT_BUTTON, self.on_finished, self.button_finished) # end wxGlade # create a pubsub receiver Publisher().subscribe(self.update_display, "update") Publisher().subscribe(self.final_report, "report") Publisher().subscribe(self.update_progress_bar, "progress_bar") Publisher().subscribe(self.update_current_class, "change_class")
def __init__(self, parent): wx.Frame.__init__(self, parent, title=u"Addition Frame") self.model = WatchableDict() self.model["a"] = 2 self.model["b"] = 3 self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize) sizer = wx.BoxSizer(wx.VERTICAL) gb_sizer = wx.GridBagSizer(5, 5) gb_sizer.SetFlexibleDirection(wx.BOTH) gb_sizer.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED) self.spin_ctrl_a = wx.SpinCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 10, 0) gb_sizer.Add(self.spin_ctrl_a, wx.GBPosition(0, 0), wx.GBSpan(1, 1), wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 5) pywatch.wx.ValueChanger(self.spin_ctrl_a, self.model, "a") self.static_text = wx.StaticText(self, wx.ID_ANY, u"+", wx.DefaultPosition, wx.DefaultSize, 0) self.static_text.Wrap(-1) gb_sizer.Add(self.static_text, wx.GBPosition(0, 1), wx.GBSpan(1, 1), wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 5) self.spin_ctrl_b = wx.SpinCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 0, 10, 0) gb_sizer.Add(self.spin_ctrl_b, wx.GBPosition(0, 2), wx.GBSpan(1, 1), wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 0) pywatch.wx.ValueChanger(self.spin_ctrl_b, self.model, "b") self.static_text_out = wx.StaticText(self, wx.ID_ANY, u"{}", wx.DefaultPosition, wx.DefaultSize, 0) self.static_text_out.Wrap(-1) gb_sizer.Add(self.static_text_out, wx.GBPosition(1, 0), wx.GBSpan(1, 3), wx.ALL | wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 5) pywatch.wx.LabelWatcher(self.static_text_out, self.model, ("a", "b", lambda: self.model["a"] + self.model["b"])) self.gauge = wx.Gauge(self, wx.ID_ANY, 20, wx.DefaultPosition, wx.DefaultSize, wx.GA_HORIZONTAL) self.gauge.SetValue(0) gb_sizer.Add(self.gauge, wx.GBPosition(2, 0), wx.GBSpan(1, 3), wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL, 0) pywatch.wx.ValueWatcher(self.gauge, self.model, ("a", "b", lambda: self.model["a"] + self.model["b"])) gb_sizer.AddGrowableCol(0) gb_sizer.AddGrowableCol(2) sizer.Add(gb_sizer, 1, wx.EXPAND | wx.ALL, 5) self.SetSizer(sizer) self.Layout() self.Centre(wx.BOTH)
def setupMenuBar(self, parent): # ????? self.t1 = wx.TextCtrl(parent, size=(550, 260), pos=(15, 10), style=wx.TE_MULTILINE) # ???? self.find_button = wx.Button( parent, -1, u"??(B)...", (16, 280), (80, 30)) # size = (70,25), self.clear_button = wx.Button( parent, -1, u"??(L)", (16 + 96, 280), (80, 30)) self.copy_button = wx.Button( parent, -1, u"??(C)", (16 + 96 * 2, 280), (80, 30)) self.save_button = wx.Button( parent, -1, u"??(S)", (16 + 96 * 3, 280), (80, 30)) self.stop_button = wx.Button( parent, -1, u"??(T)", (16 + 96 * 4, 280), (80, 30)) # ?????? self.version_box = wx.CheckBox(parent, -1, u"??(V)", (500, 280)) self.time_box = wx.CheckBox(parent, -1, u"??(D)", (500, 280 + 20)) self.md5_box = wx.CheckBox(parent, -1, u"MD5(M)", (500, 280 + 20 * 2)) self.sha1_box = wx.CheckBox( parent, -1, u"SHA1(H)", (500, 280 + 20 * 3)) self.crc32_box = wx.CheckBox( parent, -1, u"CRC32(R)", (500, 280 + 20 * 4)) # ????? self.static1 = wx.StaticText( parent, -1, '??', pos=(20, 320), size=(50, 25)) self.static2 = wx.StaticText( parent, -1, '??', pos=(20, 350), size=(50, 25)) self.sigle_gauge = wx.Gauge(parent, -1, 100, (60, 320), (420, 20)) self.totle_gauge = wx.Gauge(parent, -1, 100, (60, 350), (420, 20)) # self.gauge.SetBezelFace(3) # self.gauge.SetShadowWidth(3) # ????? self.version_box.SetValue(True) self.time_box.SetValue(True) self.md5_box.SetValue(True) self.sha1_box.SetValue(True) self.crc32_box.SetValue(True) self.stop_button.Enable(False) # ???? self.Bind(wx.EVT_CLOSE, self.closewindows) self.Bind(wx.EVT_BUTTON, self.find_file, self.find_button) self.Bind(wx.EVT_BUTTON, self.clear_text, self.clear_button) self.Bind(wx.EVT_BUTTON, self.copy_text, self.copy_button) self.Bind(wx.EVT_BUTTON, self.save_file, self.save_button) self.Bind(wx.EVT_BUTTON, self.stop_calc, self.stop_button) # self.Bind(wx.EVT_IDLE, self.onidle) self.file_cnt = 0 self.deal_file_cnt = 0