Example #1
0
    def _create_btn_sizer_no2(self, parent):
        # Create Buttons
        # TODO: Tooltips and bindings

        btn_sizer = wx.BoxSizer(wx.HORIZONTAL)

        # TODO: Two lines. Top line has filter peaks, Peak number, combobox and arrows
        #  Line two has hide peak (with eye icon), show hidden peaks, and show rsd button

        self.hide_peak_button = buttons.GenBitmapTextButton(
            self, -1, None, "Show Peak")
        self.update_show_hide_peak_btn()

        self.show_hidden_button = buttons.GenBitmapTextButton(
            self, -1, None, "Show Hidden Peaks")
        self.update_hidden_peaks_btn()

        self.show_rsd_check = wx.CheckBox(parent, label="Show  `± %RSD`")
        self.show_rsd_check.SetValue(1)

        btn_sizer.Add(self.hide_peak_button, 0, wx.EXPAND, 0)
        btn_sizer.Add(self.show_hidden_button, 0, wx.EXPAND, 0)
        btn_sizer.AddSpacer(20)
        btn_sizer.Add(self.show_rsd_check, 0, wx.EXPAND | wx.ALL, 2)

        return btn_sizer
Example #2
0
    def __init__(self, *args, **kwds):
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.splitter = ProportionalSplitter(
            self)  #, style=wx.SP_3D|wx.SP_BORDER)
        self.panel = wx.Panel(self.splitter)
        self.notebook = wx.Notebook(self.panel, -1, style=wx.NB_BOTTOM)
        self.project_notebook_pane = wx.Panel(self.notebook,
                                              -1,
                                              style=wx.TAB_TRAVERSAL)
        self.SetIcon(wx.Icon(consts.fileIco, wx.BITMAP_TYPE_ICO))
        self.statusbar = self.CreateStatusBar(1, 0)

        # Side Buttons
        self.buttonPanel = wx.Panel(self)
        self.downloadButton = buttons.GenBitmapTextButton(
            self.buttonPanel, -1, wx.Bitmap(consts.icon_download),
            _("Download"))  #, size=(95, 25))
        self.updatesButton = buttons.GenBitmapTextButton(
            self.buttonPanel, -1, wx.Bitmap(consts.icon_updates),
            _("Get Updates"))  #, size=(95, 25))
        self.refreshButton = buttons.GenBitmapTextButton(
            self.buttonPanel, -1, wx.Bitmap(consts.icon_refresh),
            _("Refresh"))  #, size=(95, 25))
        #self.updateStatusButton = buttons.GenBitmapTextButton(self.buttonPanel, -1, wx.Bitmap(consts.icon_refresh), _("Update Status"))#, size=(95, 25))

        self.notebook_il = wx.ImageList(16, 16)
        self.notebook_il.Add(wx.Bitmap(consts.icon_project_details))
        self.notebook.SetImageList(self.notebook_il)

        self.projectDetails = wx.TextCtrl(self.project_notebook_pane,
                                          style=wx.TE_MULTILINE | wx.TE_RICH
                                          | wx.TE_READONLY)
        self.details = detailsTab(self.notebook)

        # Create list view
        self.list = VirtualList(self.splitter, self.details)

        # Create Popup menu for self.list
        self.__popup_menu()
        self.__create_menu()
        self.__set_properties()
        self.__do_layout()
        self.__bind_events()

        plugins.load(consts.dirPlugins, self)
        for name, instance, type, ver in plugins.InterfacePluginList:
            instance.start()

        if len(plugins.OSPluginList) < 1:
            wx.MessageBox(
                _("No OS plugins were loaded. Make sure you have OS plugins in "
                  ) + consts.dirPlugins + ". " +
                _("Check the log for more details."))
            sys.exit(1)
Example #3
0
    def __init__(self, *args, **kwds):
        kwds["style"] = wx.DEFAULT_DIALOG_STYLE
        wx.Dialog.__init__(self, *args, **kwds)
        self.SetIcon(wx.Icon(consts.fileIco, wx.BITMAP_TYPE_ICO))
        self.bitmap = wx.StaticBitmap(self, -1, wx.Bitmap(consts.fileLogo))
        self.welcomeText = wx.StaticText(self, -1, consts.welcome_message)
        self.newText = wx.StaticText(
            self, -1, _("To get started, create a new project."))
        self.nameTextCtrl = wx.TextCtrl(self, -1,
                                        platform.node())  #, size=(120,20))
        self.choice = wx.Choice(self, -1, choices=[], style=wx.CB_SORT)

        # Append the plugins into the combo box
        for name, instance, type, ver in plugins.OSPluginList:
            self.choice.Append(name)
        self.choice.Select(0)

        self.newProjectButton = buttons.GenBitmapTextButton(
            self, -1, wx.Bitmap(consts.icon_new),
            _("New Project"))  #, size=(110, 25))
        self.static_line = wx.StaticLine(self, -1)
        self.openTxt = wx.StaticText(self, -1, _("Open a project:"))
        self.openProjBox = wx.Choice(self,
                                     -1,
                                     choices=[_('Browse...')],
                                     style=wx.CB_SORT)

        self.projects = []
        for root, dirs, files in os.walk(consts.dirProjects):
            for item in files:
                if item.endswith(consts.appFileExt):
                    self.openProjBox.Append(item[:-6])
                    self.projects.append(os.path.join(root, item))

        try:
            self.openProjBox.Select(1)
        except:
            self.openProjBox.Select(0)

        self.openProjectButton = buttons.GenBitmapTextButton(
            self, -1, wx.Bitmap(consts.icon_open),
            _("Open Project"))  #, size=(120, 25))

        self.SetTitle(consts.welcome_message)
        self.welcomeText.SetFont(
            wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))

        self.__do_layout()
        self.Bind(wx.EVT_BUTTON, self.OnNewProject, self.newProjectButton)
        self.Bind(wx.EVT_BUTTON, self.OnOpenProject, self.openProjectButton)
    def __init_ctrls(self, prnt):
        wx.Panel.__init__(self, id=wxID_BOTTOM_WINDOW, name=u'Panel',
                          parent=prnt, style=wx.TAB_TRAVERSAL)


        self.display = ListCtrl(self, -1, size=wx.Size(520, -1))

        #self.display.Bind(wx.EVT_LIST_ITEM_FOCUSED, self.main.on_item_selected,
        #                  self.display)

        self.display.Bind(wx.EVT_LIST_ITEM_SELECTED, self.main.on_item_selected,
                          self.display)

        self.preview = buttons.GenBitmapTextButton(self, wxID_AUTOPREVIEW,
                                                   wx.Bitmap(utils.icon_path(u'preview.png'),
                                                   wx.BITMAP_TYPE_PNG), _(u"Preview"), size=(-1, 26))
        self.Bind(wx.EVT_BUTTON, self.main.on_preview_button,
                  id=wxID_AUTOPREVIEW)

        self.go = buttons.GenBitmapTextButton(self, wxID_GO,
                                              wx.Bitmap(utils.icon_path(u'go.png'), wx.BITMAP_TYPE_PNG),
                                              _(u"Go!"), size=(-1, 26))
        self.go.Enable(False)
        self.go.Bind(wx.EVT_BUTTON, self.main.rename_items, id=wxID_GO)

        self.imgPreview = wx.CheckBox(id=wxID_IMGPREVIEW,
                                      label=_(u"Show image thumbnails"), name=u'imgPreview', parent=self,
                                      style=0)
        self.imgPreview.SetToolTipString(_(u"Can slow preview considerably"))
        self.imgPreview.SetValue(False)
        self.imgPreview.Bind(wx.EVT_CHECKBOX, self.__refresh_picker)

        self.thumbSize = wx.Choice(id=wxID_THUMBSIZE,
                                   choices=[u'32', u'64', u'128', u'256'],
                                   name=u'dirsPlace', parent=self, size=wx.Size(62, -1),
                                   style=0)
        self.thumbSize.SetSelection(1)
        self.thumbSize.SetToolTipString(_(u"Thumbnail Size"))
        self.thumbSize.Bind(wx.EVT_CHOICE, self.__set_thumb_size)

        if not utils.is_pil_loaded():
            self.imgPreview.SetValue(False)
            self.imgPreview.Enable(False)
            self.thumbSize.Enable(False)

        self.autoPreview = wx.CheckBox(id=wxID_AUTOPREVIEW,
                                       label=_(u"Automatic Preview"), name=u'autoPreview', parent=self,
                                       style=0)
        self.autoPreview.SetToolTipString(_(u"Disable when working with many items"))
        self.autoPreview.SetValue(True)
    def __init__(self):
        wx.Frame.__init__(self, None, -1, "Generic Button Example",
                            size=(500, 500))
        panel = wx.Panel(self, -1)
        sizer = wx.FlexGridSizer(1, 3, 20, 20)
        b = wx.Button(panel, -1, 'A wx.Button')
        b.SetDefault()
        sizer.Add(b)
        b = wx.Button(panel, -1, 'non-default wx.Button')
        sizer.Add(b)
        sizer.Add((10,10))
        b = buttons.GenButton(panel, -1, 'Genric Button')#基本的通用按钮
        sizer.Add(b)

        b = buttons.GenButton(panel, -1, 'disabled Generic')#无效的通用按钮
        b.Enable(False)
        sizer.Add(b)
        b = buttons.GenButton(panel, -1, 'F')#自定义尺寸和颜色的按钮
        b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False))
        b.SetBezelWidth(5)
        b.SetBackgroundColour("Navy")
        b.SetForegroundColour("white")
        b.SetToolTipString("This is a BIG button...")
        sizer.Add(b)
        bmp = wx.Image("Pause.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap()
        b = buttons.GenBitmapButton(panel, -1, bmp)#通用位图按钮
        sizer.Add(b)
        self.btest = buttons.GenBitmapToggleButton(panel, -1, bmp)#通用位图开关按钮
        sizer.Add(self.btest)
        b = buttons.GenBitmapTextButton(panel, -1, bmp, 'Bitmapped Text',size=(375, 75))#位图文本按钮
        b.SetUseFocusIndicator(False)
        sizer.Add(b)
        b = buttons.GenToggleButton(panel, -1, 'Toggle Button')#通用开关按钮
        sizer.Add(b)
        panel.SetSizer(sizer)
Example #6
0
    def MakeButton(self):

        if self.cpStyle & wx.CP_GTK_EXPANDER:
            return None

        selection = self.btnRB.GetSelection()

        if selection == 0:  # standard wx.Button
            btn = wx.Button(self.cp, -1, self.label1)
        elif selection == 1:  # buttons.GenButton
            btn = buttons.GenButton(self.cp, -1, self.label1)
        elif selection == 2:  # buttons.GenBitmapButton
            bmp = images.Smiles.GetBitmap()
            btn = buttons.GenBitmapButton(self.cp, -1, bmp)
        elif selection == 3:  # buttons.GenBitmapTextButton
            bmp = images.Mondrian.GetBitmap()
            btn = buttons.GenBitmapTextButton(self.cp, -1, bmp, self.label1)
        elif selection == 4:  # buttons.ThemedGenButton
            btn = buttons.ThemedGenButton(self.cp, -1, self.label1)
        elif selection == 5:  # buttons.ThemedGenBitmapTextButton
            bmp = images.Mondrian.GetBitmap()
            btn = buttons.ThemedGenBitmapTextButton(self.cp, -1, bmp,
                                                    self.label1)

        return btn
Example #7
0
    def __init__(self):
        wx.Frame.__init__(self,
                          None,
                          -1,
                          'Generic Button Example',
                          size=(500, 400))
        panel = wx.Panel(self, -1)

        #Can also have rows=x. Can cause errors if set wrongly
        #Don't need the n = ... part, but helped for troubleshooting
        sizer = wx.FlexGridSizer(cols=3, vgap=20, hgap=20)
        b = wx.Button(panel, -1, "A wx.Button")
        b.SetDefault()
        sizer.Add(b)

        #Interesting, can reuse b, now that it is saved to sizer
        b = wx.Button(panel, -1, "non-default wx.Button")
        sizer.Add(b)

        sizer.Add((10, 10))

        b = buttons.GenButton(panel, -1, 'Generic Button')
        sizer.Add(b)

        b = buttons.GenButton(panel, -1, 'disabled Generic')
        b.Enable(False)
        sizer.Add(b)

        b = buttons.GenButton(panel, -1, 'bigger')
        b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False))
        b.SetBezelWidth(5)
        #?? Does capitalisation matter
        b.SetBackgroundColour("Navy")
        b.SetForegroundColour("white")
        b.SetToolTipString("This is a BIG button...")
        sizer.Add(b)

        bmp = wx.Image("bitmap.bmp", wx.BITMAP_TYPE_BMP).ConvertToBitmap()
        b = buttons.GenBitmapButton(panel, -1, bmp)
        sizer.Add(b)

        b = buttons.GenBitmapToggleButton(panel, -1, bmp)
        sizer.Add(b)

        b = buttons.GenBitmapTextButton(panel,
                                        -1,
                                        bmp,
                                        "Bitmapped Text",
                                        size=(175, 175))
        #?? What do again
        b.SetUseFocusIndicator(False)
        sizer.Add(b)

        b = buttons.GenToggleButton(panel, -1, "ToggleButton")
        sizer.Add(b)

        panel.SetSizer(sizer)
Example #8
0
	def _create_buttons(self):
		self.btn_sizer = wx.BoxSizer(wx.HORIZONTAL)
		
		self.sort_filter_btn = buttons.GenBitmapTextButton(self, -1, None, "Sort & Filter  ")
		self.sort_filter_btn.SetBitmapLabel(get_icon("data-filter", 24))
		self.expand_all_btn = buttons.GenButton(self, label="  Expand All  ")
		self.collapse_all_btn = buttons.GenButton(self, label="  Collapse All  ")
		
		self.btn_sizer.Add(self.sort_filter_btn, 0, wx.EXPAND, 0)
		self.btn_sizer.Add(self.expand_all_btn, 0, wx.EXPAND, 0)
		self.btn_sizer.Add(self.collapse_all_btn, 0, wx.EXPAND, 0)
Example #9
0
    def __init__(self):
        wx.Frame.__init__(self,
                          None,
                          -1,
                          "Generic Button Example",
                          size=(500, 350))
        panel = wx.Panel(self, -1)

        sizer = wx.FlexGridSizer(3, 3, 20, 20)
        b = wx.Button(panel, -1, "A wx.Button")
        b.SetDefault()
        sizer.Add(b)

        b = wx.Button(panel, -1, "non-default wx.Button")
        sizer.Add(b)

        b = buttons.GenButton(panel, -1, "Generic Button")
        sizer.Add(b)

        b = buttons.GenButton(panel, -1, "disabled Generic")
        b.Enable(False)
        sizer.Add(b)

        b = buttons.GenButton(panel, -1, "bigger")
        b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD))
        b.SetBezelWidth(5)
        b.SetBackgroundColour("Navy")
        b.SetForegroundColour("white")
        b.SetToolTip("This is a BIG button!")
        sizer.Add(b)

        bmp = wx.Image("img/button-off.png",
                       wx.BITMAP_TYPE_PNG).ConvertToBitmap()

        b = buttons.GenBitmapButton(panel, -1, bmp)
        sizer.Add(b)

        b = buttons.GenBitmapToggleButton(panel, -1, bmp)
        sizer.Add(b)

        b = buttons.GenBitmapTextButton(panel,
                                        -1,
                                        bmp,
                                        "Bitmap Text",
                                        size=(175, 75))
        b.SetUseFocusIndicator(False)
        sizer.Add(b)

        b = buttons.GenToggleButton(panel, -1, "Toggle Button")
        sizer.Add(b)

        panel.SetSizer(sizer)
 def __create_undo_redo(self, label):
     """Deletes and creates a new button, hack to change image."""
     if label == _("Undo"):
         img = wx.Bitmap(utils.icon_path(u'undo.ico'), wx.BITMAP_TYPE_ICO)
     else:
         img = wx.Bitmap(utils.icon_path(u'redo.ico'), wx.BITMAP_TYPE_ICO)
     if hasattr(self, 'undoRedo'):
         self.undoRedo.Destroy()
     self.undoRedo = buttons.GenBitmapTextButton(self, wxID_UNDOREDO, img, label, size=(-1, 26))
     # do not use wx.EVT_BUTTON, causes seg fault
     self.undoRedo.Bind(wx.EVT_LEFT_DOWN, self.main.undo_rename, id=wxID_UNDOREDO)
     self.buttonSizer.Insert(2, self.undoRedo, proportion=0, flag=wx.LEFT, border=25)
     self.Layout()
    def __init__(self):
        wx.Frame.__init__(self,
                          None,
                          -1,
                          'Generic Button Example',
                          size=(500, 350))
        panel = wx.Panel(self, -1)

        sizer = wx.FlexGridSizer(1, 3, 20, 20)
        b = wx.Button(panel, -1, "A wx.Button")
        b.SetDefault()
        sizer.Add(b)

        b = wx.Button(panel, -1, "non-default wx.Button")
        sizer.Add(b)
        sizer.Add((10, 10))

        b = buttons.GenButton(panel, -1, 'Generic Button')
        sizer.Add(b)

        b = buttons.GenButton(panel, -1, 'disabled Generic')
        b.Enable(False)
        sizer.Add(b)

        b = buttons.GenButton(panel, -1, 'bigger')
        b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False))
        b.SetBezelWidth(5)
        b.SetBackgroundColour("Navy")
        b.SetForegroundColour("white")
        b.SetToolTipString("This is a BIG button...")
        sizer.Add(b)

        bmp = wx.Image("bitmap.bmp", wx.BITMAP_TYPE_BMP).ConvertToBitmap()
        b = buttons.GenBitmapButton(panel, -1, bmp)
        sizer.Add(b)

        b = buttons.GenBitmapToggleButton(panel, -1, bmp)
        sizer.Add(b)

        b = buttons.GenBitmapTextButton(panel,
                                        -1,
                                        bmp,
                                        "Bitmapped Text",
                                        size=(175, 75))
        b.SetUseFocusIndicator(False)
        sizer.Add(b)

        b = buttons.GenToggleButton(panel, -1, "Toggle Button")
        sizer.Add(b)

        panel.SetSizer(sizer)
Example #12
0
    def __init__(self):
        wx.Frame.__init__(self,
                          None,
                          -1,
                          'Generic Button Example',
                          size=(500, 350))
        panel = wx.Panel(self, -1)
        sizer = wx.FlexGridSizer(4, 3, 20, 20)
        b = wx.Button(panel, -1, "A wx.Button")
        b.SetDefault()
        sizer.Add(b)
        b = wx.Button(panel, -1, "non-default wx.Button")
        sizer.Add(b)
        sizer.Add((10, 10))

        b = buttons.GenButton(panel, -1,
                              'Generic Button')  # Базовая типовая кнопка
        sizer.Add(b)
        b = buttons.GenButton(
            panel, -1, 'disabled Generic')  # Блокированная типовая кнопка
        b.Enable(False)
        sizer.Add(b)
        b = buttons.GenButton(
            panel, -1,
            'bigger')  # Кнопка с заданным пользователем размером и цветом
        b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False))
        b.SetBezelWidth(5)
        b.SetBackgroundColour("Navy")
        b.SetForegroundColour("white")
        b.SetToolTip("This is a BIG button...")
        sizer.Add(b)

        bmp = wx.Image("bird.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap()
        b = buttons.GenBitmapButton(
            panel, -1, bmp)  # Типовая кнопка с битовым изображением
        sizer.Add(b)
        b = buttons.GenBitmapToggleButton(panel, -1, bmp)
        sizer.Add(b)  # Типовая кнопка-переключатель с битовым изображением
        b = buttons.GenBitmapTextButton(
            panel, -1, bmp, "Bitmapped Text",
            size=(175, 75))  # Кнопка с битовым изображением и текстом
        b.SetUseFocusIndicator(False)
        sizer.Add(b)
        b = buttons.GenToggleButton(
            panel, -1, "Toggle Button")  # Типовая кнопка-переключатель
        sizer.Add(b)
        panel.SetSizer(sizer)
Example #13
0
    def OnButtonChoice(self, event):

        selection = event.GetSelection()

        if self.cp.IsExpanded():
            label = self.label1
        else:
            label = self.label2

        style = self.cp.GetWindowStyleFlag()
        if selection < 4:
            style &= ~PCP.CP_GTK_EXPANDER
        else:
            style |= PCP.CP_GTK_EXPANDER

        self.gtkText.Enable(selection == 4)
        self.gtkChoice.Enable(selection == 4)

        self.Freeze()
        cp = PCP.PyCollapsiblePane(self, label=self.label1, style=style)
        self.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED, self.OnPaneChanged, cp)
        self.MakePaneContent(cp.GetPane())
        self.GetSizer().Replace(self.cp, cp)

        self.cp.Destroy()
        self.cp = cp
        self.Thaw()

        if selection == 0:  # standard wx.Button
            btn = wx.Button(self.cp, -1, label)
        elif selection == 1:  # buttons.GenButton
            btn = buttons.GenButton(self.cp, -1, label)
        elif selection == 2:  # buttons.GenBitmapButton
            bmp = GetSmilesBitmap()
            btn = buttons.GenBitmapButton(self.cp, -1, bmp)
        elif selection == 3:  # buttons.GenBitmapTextButton
            bmp = GetMondrianBitmap()
            btn = buttons.GenBitmapTextButton(self.cp, -1, bmp, label)

        if selection < 4:
            self.cp.SetButton(btn)
            btn.Bind(wx.EVT_BUTTON, self.OnToggle)
        else:
            self.cp.SetExpanderDimensions(*self.GetUserSize())

        self.OnPaneChanged(None)
        self.Layout()
Example #14
0
 def AddMenuTool(self, id, text, help_string, callback=None, toggle=0):
    if not toggle:
       button = buttons.GenBitmapTextButton(
           self, id, None, text, size=wx.Size(48, 28))
    else:
       button = buttons.GenBitmapTextToggleButton(
           self, id, None, text, size=wx.Size(48,28))
    button.SetBitmapLabel(gamera_icons.getToolbarMenuBitmap())
    button.SetBezelWidth(1)
    button.SetUseFocusIndicator(False)
    button.SetToolTipString(help_string)
    if callback:
       wx.EVT_BUTTON(self, id, callback)
    self.sizer.Add(button, flag=wx.ALIGN_CENTER)
    self.sizer.SetSizeHints(self)
    self.controls.append(button)
    return button
Example #15
0
    def _create_hits_btn_sizer(self, parent):
        # Create Buttons
        # TODO: Tooltips and bindings

        btn_sizer = wx.BoxSizer(wx.HORIZONTAL)

        btn_sizer.Add(wx.StaticText(parent, label="Hits:"), 1,
                      wx.ALIGN_BOTTOM | wx.LEFT, 8)

        self.filter_hits_btn = buttons.GenBitmapTextButton(
            self, -1, None, "Filter Hits  ")
        self.filter_hits_btn.SetBitmapLabel(get_icon("data-filter", 24))

        btn_sizer.Add(self.filter_hits_btn, 0, wx.EXPAND | wx.ALIGN_RIGHT, 0)
        btn_sizer.AddSpacer(20)

        return btn_sizer
Example #16
0
 def __init__(self):
     wx.Frame.__init__(self,
                       None,
                       -1,
                       "Generic Button Example",
                       size=(500, 350))
     panel = wx.Panel(self, -1)
     sizer = wx.FlexGridSizer(1, 3, 20, 20)
     b = wx.Button(panel, -1, "A wx.Button")
     b.SetDefault()
     b.SetToolTipString("a wx.Button")
     sizer.Add(b)
     b = wx.Button(panel, -1, "non-default wx.Button")
     sizer.Add(b)
     sizer.Add((10, 10))
     b = buttons.GenButton(panel, -1, "Genric Button")
     sizer.Add(b)
     b = buttons.GenButton(panel, -1, "disabled Generic")
     b.Enable(False)
     sizer.Add(b)
     b = buttons.GenButton(panel, -1, 'bigger')
     b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False))
     b.SetBezelWidth(5)
     b.SetBackgroundColour("Navy")
     b.SetForegroundColour("white")
     b.SetToolTipString("this is a Big button..")
     sizer.Add(b)
     bmp = wx.Bitmap("img/002.jpg", wx.BITMAP_TYPE_JPEG)
     b = buttons.GenBitmapButton(panel, -1, bmp)
     sizer.Add(b)
     b = buttons.GenBitmapToggleButton(panel, -1, bmp)
     sizer.Add(b)
     b = buttons.GenBitmapTextButton(panel,
                                     -1,
                                     bmp,
                                     "Bitmapped Text",
                                     size=(175, 75))
     self.Bind(wx.EVT_BUTTON, self.OnClick, b)
     b.SetUseFocusIndicator(False)
     sizer.Add(b)
     b = buttons.GenToggleButton(panel, -1, "Toggle Button")
     sizer.Add(b)
     b = wx.ToggleButton(panel, -1, "on/off")
     self.Bind(wx.EVT_TOGGLEBUTTON, self.OnClick, b)
     sizer.Add(b)
     panel.SetSizer(sizer)
Example #17
0
    def __init__(self):
        wx.Frame.__init__(self, None, -1, 'Generic Button Example',
                          size=(500, 350))
        panel = wx.Panel(self, -1)

        sizer = wx.FlexGridSizer(4, 3, 20, 20)
        btn = wx.Button(panel, -1, "A wx.Button")
        btn.SetDefault()
        sizer.Add(btn)

        btn = wx.Button(panel, -1, "Non-default wx.Button")
        sizer.Add(btn)
        sizer.Add((10, 10))

        btn = buttons.GenButton(panel, -1, 'Generic Button')  # 基本的通用按钮
        sizer.Add(btn)

        btn = buttons.GenButton(panel, -1, 'Disabled Generic')  # 无效的通用按钮
        btn.Enable(False)
        sizer.Add(btn)

        btn = buttons.GenButton(panel, -1, 'Bigger')  # 自定义尺寸和颜色的按钮
        btn.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False))
        btn.SetBezelWidth(5)
        btn.SetBackgroundColour("Navy")
        btn.SetForegroundColour("White")
        btn.SetToolTipString("This is a BIG button...")
        sizer.Add(btn)

        bmp = wx.Image("bitmap.bmp", wx.BITMAP_TYPE_BMP).ConvertToBitmap()
        btn = buttons.GenBitmapButton(panel, -1, bmp)  # 通用位图按钮
        sizer.Add(btn)

        btn = buttons.GenBitmapToggleButton(panel, -1, bmp)  # 通用位图开关按钮
        sizer.Add(btn)

        btn = buttons.GenBitmapTextButton(panel, -1, bmp, "Bitmap Text",
                                          size=(175, 75))  # 位图文本按钮
        btn.SetUseFocusIndicator(False)
        sizer.Add(btn)

        btn = buttons.GenToggleButton(panel, -1, "Toggle Button")  # 通用开关按钮
        sizer.Add(btn)

        panel.SetSizer(sizer)
Example #18
0
    def test_lib_buttons1(self):
        
        btn = buttons.GenButton(self.frame, label='label')
        btn = buttons.GenButton(self.frame, -1, 'label', (10,10), (100,-1), wx.BU_LEFT)
        
        bmp = wx.Bitmap(pngFile)
        btn = buttons.GenBitmapButton(self.frame, bitmap=bmp)
        btn = buttons.GenBitmapTextButton(self.frame, label='label', bitmap=bmp)
        
        btn.SetBitmapFocus(bmp)
        btn.SetBitmapDisabled(bmp)
        btn.SetBitmapSelected(bmp)

        btn = buttons.GenBitmapToggleButton(self.frame, bitmap=bmp)
        btn.SetToggle(True)

        self.assertTrue(btn.GetValue())
        self.assertEqual(btn.GetBitmapLabel(), bmp)
Example #19
0
 def __init__(self):
     wx.Frame.__init__(self,
                       None,
                       -1,
                       'Generic Button Example',
                       size=(500, 350))
     panel = wx.Panel(self, -1)
     sizer = wx.FlexGridSizer(1, 3, 20, 20)
     b = wx.Button(panel, -1, "A wx.Button")
     b.SetDefault()
     sizer.Add(b)
     b = wx.Button(panel, -1, "non-default wx.Button")
     sizer.Add(b)
     sizer.Add((10, 10))
     b = buttons.GenButton(panel, -1, 'Generic Button')
     sizer.Add(b)
     b = buttons.GenButton(panel, -1, 'disabled Generic')
     b.Enable(False)
     sizer.Add(b)
     b = buttons.GenButton(panel, -1, 'bigger')
     b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False))
     b.SetBezelWidth(5)
     b.SetBackgroundColour("Navy")
     b.SetForegroundColour("white")
     b.SetToolTipString("This is a BIG button...")
     sizer.Add(b)
     bmp = wx.Image(
         "C:\\Users\\Ashish\\.eclipse\\231700603\\configuration\\org.eclipse.equinox.launcher\\com.jrockit.mc.rcp.application_5.3.0.159881\\splash.bmp",
         wx.BITMAP_TYPE_BMP).ConvertToBitmap()
     b = buttons.GenBitmapButton(panel, -1, bmp)
     sizer.Add(b)
     b = buttons.GenBitmapToggleButton(panel, -1, bmp)
     sizer.Add(b)
     b = buttons.GenBitmapTextButton(panel,
                                     -1,
                                     bmp,
                                     "Bitmapped Text",
                                     size=(175, 75))
     b.SetUseFocusIndicator(False)
     sizer.Add(b)
     b = buttons.GenToggleButton(panel, -1, "Toggle Button")
     sizer.Add(b)
     panel.SetSizer(sizer)
Example #20
0
    def __init__(self, pb, padre, nombre, posic, tamano, imagen, texto, accion,
                 tip):
        #- Tipo de botón segun el tipo
        boton = None
        img = None

        #- Intentamos cargar la imagen para el botón
        if imagen != '':
            if imagen in os.listdir(DIR_IMG + '/32/'):
                imagen = DIR_IMG + '/32/' + imagen

            try:
                img = wx.Image(imagen, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
            except:
                imagen = ''
        #
        if imagen != '' and texto != '':  # Boton con Imagen y Texto
            boton = wxbuttons.GenBitmapTextButton(padre, -1, img, texto)
        elif imagen != '':  # Boton con imagen
            boton = wxbuttons.GenBitmapButton(padre, -1, img)
        else:  # Boton con texto
            boton = wxbuttons.GenButton(padre, -1, texto)

        #- Asignamos Propiedades
        boton.SetToolTip(tip)
        boton.SetSize(tamano)
        boton.SetPosition(posic)
        boton.SetBezelWidth(2)

        #- Asignamos el Evento
        boton.Bind(wx.EVT_BUTTON, self.onPressButton)
        boton.Bind(wx.EVT_ENTER_WINDOW, self.onMouseOn)
        boton.Bind(wx.EVT_LEAVE_WINDOW, self.onMouseOut)

        #
        self._name = nombre
        self.__pb = pb  # Padre Base, contiene la accion a ejecutar
        self.__boton = boton  # Objeto Boton
        self.__accion = accion  # Nombre de la accion a ejecutar
Example #21
0
    def _create_btn_sizer(self, parent):
        # Create Buttons
        # TODO: Tooltips and bindings

        btn_sizer = wx.BoxSizer(wx.HORIZONTAL)

        # TODO: Two lines. Top line has filter peaks, Peak number, combobox and arrows
        #  Line two has hide peak (with eye icon), show hidden peaks, and show rsd button

        self.filter_peaks_btn = buttons.GenBitmapTextButton(
            self, -1, None, "Filter Peaks  ")
        self.filter_peaks_btn.SetBitmapLabel(get_icon("data-filter", 24))

        self.peak_number_combo = wx.ComboBox(
            parent, size=(100, -1), validator=CharValidator("int-only"))
        self.previous_peak_btn = buttons.GenBitmapButton(parent,
                                                         bitmap=get_icon(
                                                             wx.ART_GO_BACK,
                                                             24))
        self.previous_peak_btn.SetToolTip("Previous Peak")
        self.next_peak_btn = buttons.GenBitmapButton(parent,
                                                     bitmap=get_icon(
                                                         wx.ART_GO_FORWARD,
                                                         24))
        self.next_peak_btn.SetToolTip("Next Peak")

        btn_sizer.Add(self.filter_peaks_btn, 0, wx.EXPAND, 0)
        btn_sizer.AddSpacer(20)
        btn_sizer.Add(wx.StaticText(parent, label="Peak Number: "), 1,
                      wx.ALIGN_CENTER_VERTICAL, 0)
        btn_sizer.Add(self.peak_number_combo, 0, wx.EXPAND, 0)
        btn_sizer.Add(self.previous_peak_btn, 0, wx.EXPAND, 0)
        btn_sizer.Add(self.next_peak_btn, 0, wx.EXPAND, 0)
        btn_sizer.AddSpacer(10)

        return btn_sizer
Example #22
0
    def __init__(self, parent, log):
        wx.Panel.__init__(self, parent, -1)
        self.log = log
        ##self.SetBackgroundColour("sky blue")

        sizer = wx.FlexGridSizer(1, 3, 20, 20)

        # A regular button, selected as the default button
        b = wx.Button(self, -1, "A real button")
        b.SetDefault()
        self.Bind(wx.EVT_BUTTON, self.OnButton, b)
        sizer.Add(b)

        # Same thing, but NOT set as the default button
        b = wx.Button(self, -1, "non-default")
        self.Bind(wx.EVT_BUTTON, self.OnButton, b)
        sizer.Add(b)
        sizer.Add((10, 10))

        # Plain old text button based off GenButton()
        b = buttons.GenButton(self, -1, 'Hello')
        self.Bind(wx.EVT_BUTTON, self.OnButton, b)
        sizer.Add(b)

        # Plain old text button, disabled.
        b = buttons.GenButton(self, -1, 'disabled')
        self.Bind(wx.EVT_BUTTON, self.OnButton, b)
        b.Enable(False)
        sizer.Add(b)

        # This time, we let the botton be as big as it can be.
        # Also, this one is fancier, with custom colors and bezel size.
        b = buttons.GenButton(self, -1, 'bigger')
        self.Bind(wx.EVT_BUTTON, self.OnBiggerButton, b)
        b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False))
        b.SetBezelWidth(5)
        b.SetMinSize(wx.DefaultSize)
        b.SetBackgroundColour("Navy")
        b.SetForegroundColour(wx.WHITE)
        b.SetToolTipString("This is a BIG button...")
        # let the sizer set best size
        sizer.Add(b, flag=wx.ADJUST_MINSIZE)

        # An image button
        bmp = images.Test2.GetBitmap()
        b = buttons.GenBitmapButton(self, -1, bmp)
        self.Bind(wx.EVT_BUTTON, self.OnButton, b)
        sizer.Add(b)

        # An image button, disabled.
        bmp = images.Test2.GetBitmap()
        b = buttons.GenBitmapButton(self, -1, bmp)
        self.Bind(wx.EVT_BUTTON, self.OnButton, b)
        sizer.Add(b)
        b.Enable(False)

        # An image button, using a mask to get rid of the
        # undesireable part of the image
        b = buttons.GenBitmapButton(self, -1, None)
        self.Bind(wx.EVT_BUTTON, self.OnButton, b)
        bmp = images.Bulb1.GetBitmap()
        mask = wx.Mask(bmp, wx.BLUE)
        bmp.SetMask(mask)
        b.SetBitmapLabel(bmp)
        bmp = images.Bulb2.GetBitmap()
        mask = wx.Mask(bmp, wx.BLUE)
        bmp.SetMask(mask)
        b.SetBitmapSelected(bmp)
        b.SetInitialSize()
        sizer.Add(b)

        # A toggle button
        b = buttons.GenToggleButton(self, -1, "Toggle Button")
        self.Bind(wx.EVT_BUTTON, self.OnToggleButton, b)
        sizer.Add(b)

        # An image toggle button
        b = buttons.GenBitmapToggleButton(self, -1, None)
        self.Bind(wx.EVT_BUTTON, self.OnToggleButton, b)
        bmp = images.Bulb1.GetBitmap()
        mask = wx.Mask(bmp, wx.BLUE)
        bmp.SetMask(mask)
        b.SetBitmapLabel(bmp)
        bmp = images.Bulb2.GetBitmap()
        mask = wx.Mask(bmp, wx.BLUE)
        bmp.SetMask(mask)
        b.SetBitmapSelected(bmp)
        b.SetToggle(True)
        b.SetInitialSize()
        sizer.Add(b)

        # A bitmap button with text.
        b = buttons.GenBitmapTextButton(self,
                                        -1,
                                        None,
                                        "Bitmapped Text",
                                        size=(200, 45))
        self.Bind(wx.EVT_BUTTON, self.OnButton, b)
        bmp = images.Bulb1.GetBitmap()
        mask = wx.Mask(bmp, wx.BLUE)
        bmp.SetMask(mask)
        b.SetBitmapLabel(bmp)
        bmp = images.Bulb2.GetBitmap()
        mask = wx.Mask(bmp, wx.BLUE)
        bmp.SetMask(mask)
        b.SetBitmapSelected(bmp)
        b.SetUseFocusIndicator(False)
        b.SetInitialSize()
        sizer.Add(b)

        # a flat text button
        b = buttons.GenButton(self,
                              -1,
                              'Flat buttons too!',
                              style=wx.BORDER_NONE)
        self.Bind(wx.EVT_BUTTON, self.OnButton, b)
        sizer.Add(b, flag=wx.ALIGN_CENTER_VERTICAL)

        # A flat image button
        bmp = images.Test2.GetBitmap()
        bmp.SetMaskColour("blue")
        b = buttons.GenBitmapButton(self, -1, bmp, style=wx.BORDER_NONE)
        self.Bind(wx.EVT_BUTTON, self.OnButton, b)
        sizer.Add(b)
        ##b.SetBackgroundColour("sky blue")
        ##b.SetBackgroundColour("pink")

        b = buttons.ThemedGenButton(self, -1, 'Drawn with native renderer')
        self.Bind(wx.EVT_BUTTON, self.OnButton, b)
        sizer.Add(b)

        border = wx.BoxSizer(wx.VERTICAL)
        border.Add(sizer, 0, wx.ALL, 25)
        self.SetSizer(border)
Example #23
0
    def __init__(self,
                 parent=None,
                 id=wx.ID_ANY,
                 title="SwitchHosts!",
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.DEFAULT_FRAME_STYLE,
                 cls_TaskBarIcon=None):
        wx.Frame.__init__(self, parent, id, title, pos, size, style)

        self.SetIcon(co.GetMondrianIcon())
        self.SetSizeHintsSz(wx.Size(400, 300), wx.DefaultSize)

        self.m_menubar1 = wx.MenuBar(0)
        self.m_menu1 = wx.Menu()
        self.m_menuItem_new = wx.MenuItem(self.m_menu1, wx.ID_NEW, u"新建(&N)",
                                          wx.EmptyString, wx.ITEM_NORMAL)
        self.m_menu1.AppendItem(self.m_menuItem_new)
        self.m_menu1.AppendSeparator()

        self.m_menuItem_export = wx.MenuItem(self.m_menu1, wx.NewId(),
                                             u"导出(&E)", wx.EmptyString,
                                             wx.ITEM_NORMAL)
        self.m_menu1.AppendItem(self.m_menuItem_export)
        self.m_menuItem_import = wx.MenuItem(self.m_menu1, wx.NewId(),
                                             u"导入(&I)", wx.EmptyString,
                                             wx.ITEM_NORMAL)
        self.m_menu1.AppendItem(self.m_menuItem_import)

        self.m_menu1.AppendSeparator()
        self.m_menuItem_exit = wx.MenuItem(self.m_menu1, wx.ID_EXIT, u"退出(&X)",
                                           wx.EmptyString, wx.ITEM_NORMAL)
        self.m_menu1.AppendItem(self.m_menuItem_exit)

        self.m_menubar1.Append(self.m_menu1, u"文件(&F)")

        self.m_menu2 = wx.Menu()
        self.m_menuItem_about = wx.MenuItem(self.m_menu2, wx.ID_ABOUT,
                                            u"关于(&A)", wx.EmptyString,
                                            wx.ITEM_NORMAL)
        self.m_menu2.AppendItem(self.m_menuItem_about)
        self.m_menuItem_homepage = wx.MenuItem(self.m_menu2, wx.ID_ANY,
                                               u"主页(&H)", wx.EmptyString,
                                               wx.ITEM_NORMAL)
        self.m_menu2.AppendItem(self.m_menuItem_homepage)
        self.m_menuItem_feedback = wx.MenuItem(self.m_menu2, wx.ID_ANY,
                                               u"反馈建议(&F)", wx.EmptyString,
                                               wx.ITEM_NORMAL)
        self.m_menu2.AppendItem(self.m_menuItem_feedback)
        self.m_menuItem_chkUpdate = wx.MenuItem(self.m_menu2, wx.ID_ANY,
                                                u"检查更新(&U)", wx.EmptyString,
                                                wx.ITEM_NORMAL)
        self.m_menu2.AppendItem(self.m_menuItem_chkUpdate)
        self.m_menuItem_donate = wx.MenuItem(self.m_menu2, wx.ID_ANY,
                                             u"捐赠(&D)", wx.EmptyString,
                                             wx.ITEM_NORMAL)
        self.m_menu2.AppendItem(self.m_menuItem_donate)

        self.m_menubar1.Append(self.m_menu2, u"帮助(&H)")

        self.SetMenuBar(self.m_menubar1)

        bSizer1 = wx.BoxSizer(wx.VERTICAL)

        self.m_panel1 = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition,
                                 wx.DefaultSize, wx.TAB_TRAVERSAL)
        bSizer4 = wx.BoxSizer(wx.HORIZONTAL)

        bSizer5 = wx.BoxSizer(wx.VERTICAL)

        self.m_tree = wx.TreeCtrl(self.m_panel1, wx.ID_ANY, wx.DefaultPosition, wx.Size(200, -1),
            style=wx.TR_DEFAULT_STYLE|wx.NO_BORDER|wx.TR_NO_LINES\
                |wx.TR_FULL_ROW_HIGHLIGHT#|wx.TR_HIDE_ROOT
        )

        self.m_tree.SetBackgroundColour(wx.Colour(218, 223, 230))
        self.m_tree_root = self.m_tree.AddRoot(u"hosts")
        self.m_tree_common = self.m_tree.AppendItem(self.m_tree_root,
                                                    lang.trans("common_hosts"))
        self.m_tree_origin = self.m_tree.AppendItem(self.m_tree_root,
                                                    lang.trans("origin_hosts"))
        self.m_tree_local = self.m_tree.AppendItem(self.m_tree_root,
                                                   lang.trans("local_hosts"))
        self.m_tree_online = self.m_tree.AppendItem(self.m_tree_root,
                                                    lang.trans("online_hosts"))
        self.m_tree.SetItemTextColour(self.m_tree_root, "#999999")
        self.m_tree.SetItemTextColour(self.m_tree_common, "#3333ff")
        self.m_tree.SetItemTextColour(self.m_tree_local, "#999999")
        self.m_tree.SetItemTextColour(self.m_tree_online, "#999999")
        self.m_tree.ExpandAll()
        bSizer5.Add(self.m_tree, 1, wx.ALL | wx.EXPAND, 0)

        self.image_list = wx.ImageList(16, 16)
        self.ico_folder_idx = self.image_list.Add(
            wx.ArtProvider.GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, (16, 16)))
        self.ico_folder_open_idx = self.image_list.Add(
            wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, (16, 16)))
        self.ico_file_idx = self.image_list.Add(
            wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE, wx.ART_OTHER,
                                     (16, 16)))
        self.ico_colors_idx = []
        for i, icon in enumerate(co.ICONS):
            self.ico_colors_idx.append(
                self.image_list.Add(co.GetMondrianBitmap(i)))

        self.m_tree.AssignImageList(self.image_list)

        for item_idx in (self.m_tree_root, self.m_tree_local,
                         self.m_tree_online):
            self.m_tree.SetItemImage(item_idx, self.ico_folder_idx,
                                     wx.TreeItemIcon_Normal)
            self.m_tree.SetItemImage(item_idx, self.ico_folder_open_idx,
                                     wx.TreeItemIcon_Expanded)

        self.m_staticline_left_bottom = wx.StaticLine(self.m_panel1, wx.ID_ANY,
                                                      wx.DefaultPosition,
                                                      wx.DefaultSize,
                                                      wx.LI_HORIZONTAL)
        bSizer5.Add(self.m_staticline_left_bottom, 0, wx.EXPAND | wx.ALL, 0)

        bSizer61 = wx.BoxSizer(wx.HORIZONTAL)

        self.m_btn_add = wx.BitmapButton(self.m_panel1, wx.ID_ADD,
                                         co.GetMondrianBitmap(fn="add"),
                                         wx.DefaultPosition, wx.DefaultSize,
                                         wx.BU_AUTODRAW | wx.NO_BORDER)
        self.m_btn_add.SetToolTipString(u"添加")
        bSizer61.Add(self.m_btn_add, 0,
                     wx.EXPAND | wx.TOP | wx.BOTTOM | wx.LEFT, 5)

        self.m_btn_refresh = wx.BitmapButton(
            self.m_panel1, wx.ID_REFRESH,
            co.GetMondrianBitmap(fn="arrow_refresh"), wx.DefaultPosition,
            wx.DefaultSize, wx.BU_AUTODRAW | wx.NO_BORDER)
        self.m_btn_add.SetToolTipString(u"刷新")
        bSizer61.Add(self.m_btn_refresh, 0,
                     wx.EXPAND | wx.TOP | wx.BOTTOM | wx.LEFT, 5)

        self.m_btn_edit_info = wx.BitmapButton(
            self.m_panel1, wx.ID_EDIT, co.GetMondrianBitmap(fn="pencil"),
            wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW | wx.NO_BORDER)
        self.m_btn_add.SetToolTipString(u"编辑")
        bSizer61.Add(self.m_btn_edit_info, 0,
                     wx.EXPAND | wx.TOP | wx.BOTTOM | wx.LEFT, 5)

        self.m_btn_del = wx.BitmapButton(self.m_panel1, wx.ID_DELETE,
                                         co.GetMondrianBitmap(fn="delete"),
                                         wx.DefaultPosition, wx.DefaultSize,
                                         wx.BU_AUTODRAW | wx.NO_BORDER)
        self.m_btn_del.SetToolTipString(u"删除")
        bSizer61.Add(self.m_btn_del, 0,
                     wx.EXPAND | wx.TOP | wx.BOTTOM | wx.LEFT, 5)

        bSizer5.Add(bSizer61, 0, wx.EXPAND, 5)

        bSizer4.Add(bSizer5, 1, wx.EXPAND, 5)

        self.m_staticline_main = wx.StaticLine(self.m_panel1, wx.ID_ANY,
                                               wx.DefaultPosition,
                                               wx.DefaultSize, wx.LI_VERTICAL)
        bSizer4.Add(self.m_staticline_main, 0, wx.EXPAND | wx.ALL, 0)

        bSizer6 = wx.BoxSizer(wx.VERTICAL)

        self.m_textCtrl_content = self.makeTextCtrl(bSizer6)

        bSizer7 = wx.BoxSizer(wx.HORIZONTAL)

        self.m_panel3 = wx.Panel(self.m_panel1, wx.ID_ANY, wx.DefaultPosition,
                                 wx.DefaultSize, wx.TAB_TRAVERSAL)
        bSizer71 = wx.BoxSizer(wx.HORIZONTAL)

        #        self.m_btn_save = buttons.GenBitmapTextButton(self.m_panel3, wx.ID_SAVE, co.GetMondrianBitmap(fn="disk"), u"保存")
        #        bSizer71.Add(self.m_btn_save, 0, wx.ALL, 0)

        self.m_panel3.SetSizer(bSizer71)
        self.m_panel3.Layout()
        bSizer71.Fit(self.m_panel3)
        bSizer7.Add(self.m_panel3, 1, wx.EXPAND | wx.ALL, 5)

        #        self.m_btn_apply = buttons.GenBitmapTextButton(self.m_panel1, wx.ID_APPLY,
        #            co.GetMondrianBitmap(fn="accept"), u"应用",
        #            size=wx.Size(-1, 24),
        #            style=wx.BU_AUTODRAW|wx.STATIC_BORDER)
        #        self.m_btn_apply = wx.Button(self.m_panel1, wx.ID_APPLY, u"应用", wx.DefaultPosition, wx.DefaultSize, 0)
        self.m_btn_apply = wx.BitmapButton(self.m_panel1, wx.ID_APPLY,
                                           co.GetMondrianBitmap(fn="accept"),
                                           wx.DefaultPosition, wx.Size(60, -1),
                                           wx.BU_AUTODRAW | wx.SIMPLE_BORDER)
        self.m_btn_apply.SetToolTipString(u"应用当前 hosts 方案")
        bSizer7.Add(self.m_btn_apply, 0, wx.ALL, 5)

        if cls_TaskBarIcon and os.name == "nt":
            # ubuntu 10.04 下点击这个图标时会报错,图标的菜单无法正常工作
            # ubuntu 11.04 下这个图标总是无法显示
            # 由于跨平台问题,暂时决定只在 windows 下显示快捷的任务栏图标
            # 参见:http://stackoverflow.com/questions/7144756/wx-taskbaricon-on-ubuntu-11-04
            self.m_btn_exit = buttons.GenBitmapTextButton(
                self.m_panel1, wx.ID_CLOSE, co.GetMondrianBitmap(fn="door"),
                u"隐藏")
            #            self.m_btn_exit = wx.Button(self.m_panel1, wx.ID_CLOSE, u"隐藏", wx.DefaultPosition, wx.DefaultSize, 0)
            bSizer7.Add(self.m_btn_exit, 0, wx.ALL, 5)

        self.m_staticline_right_bottom = wx.StaticLine(self.m_panel1,
                                                       wx.ID_ANY,
                                                       wx.DefaultPosition,
                                                       wx.DefaultSize,
                                                       wx.LI_HORIZONTAL)
        bSizer6.Add(self.m_staticline_right_bottom, 0, wx.EXPAND | wx.ALL, 0)

        bSizer6.Add(bSizer7, 0, wx.EXPAND, 5)

        bSizer4.Add(bSizer6, 5, wx.EXPAND, 5)

        self.m_panel1.SetSizer(bSizer4)
        self.m_panel1.Layout()
        bSizer4.Fit(self.m_panel1)
        bSizer1.Add(self.m_panel1, 1, wx.EXPAND | wx.ALL, 0)

        self.SetSizer(bSizer1)
        self.Layout()

        self.Centre(wx.BOTH)

        self.font_bold = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
        self.font_bold.SetWeight(wx.BOLD)
        self.font_normal = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
        self.font_normal.SetWeight(wx.NORMAL)

        self.font_mono = wx.Font(10,
                                 wx.ROMAN,
                                 wx.NORMAL,
                                 wx.NORMAL,
                                 faceName="Courier New")
Example #24
0
    def __init__(self, parent, id, size=(700, 500)):
        wx.Frame.__init__(self, parent, id, u'SIRC(一个简单的 IRC 聊天室)', size=size)
        # 设置窗口最小尺寸
        self.SetMinSize(size)

        # 显示窗口图标及托盘图标(伪)
        icon_big = wx.Icon('images/irc_big.ico', wx.BITMAP_TYPE_ICO)
        icon_small = wx.Icon('images/irc_small.ico', wx.BITMAP_TYPE_ICO)
        self.SetIcon(icon_small)
        self.taskicon = wx.TaskBarIcon()
        self.taskicon.SetIcon(icon_big)

        bkg = wx.Panel(self, -1)

        # 左边
        self.user_lists = wx.TextCtrl(bkg,
                                      0,
                                      u'昵称\n\n',
                                      style=wx.TE_READONLY
                                      | wx.TE_MULTILINE,
                                      size=(150, -1))
        self.start_button = wx.Button(bkg, 0, u'连接', size=(50, 30))
        self.stop_button = wx.Button(bkg, 0, u'断开', size=(50, 30))
        self.start_button.Bind(wx.EVT_BUTTON, self.start_conn)
        self.stop_button.Bind(wx.EVT_BUTTON, self.stop_conn)

        # 右边
        self.chat_contents = wx.html.HtmlWindow(bkg,
                                                0,
                                                style=wx.TE_MULTILINE
                                                | wx.TE_READONLY,
                                                size=(380, -1))
        self.chat_contents.SetBorders(1)
        self.input_area = wx.TextCtrl(bkg, 0, '', size=(100, 30))
        self.send_button = wx.Button(bkg, 0, u'发送', size=(50, 30))
        self.send_button.Bind(wx.EVT_BUTTON, self.send_message)

        # 布局
        hbox0 = wx.BoxSizer()
        hbox0.Add(self.start_button,
                  proportion=4,
                  flag=wx.EXPAND | wx.ALL,
                  border=0)
        hbox0.Add(self.stop_button,
                  proportion=4,
                  flag=wx.EXPAND | wx.ALL,
                  border=0)

        vbox0 = wx.BoxSizer(wx.VERTICAL)
        vbox0.Add(self.user_lists,
                  proportion=6,
                  flag=wx.EXPAND | wx.ALL,
                  border=5)
        vbox0.Add(hbox0, proportion=0, flag=wx.EXPAND | wx.ALL, border=5)

        hbox2 = wx.BoxSizer()

        # 表情
        self.smileys = {
            ':-) ': 'images/Smiley_Smile.ico',
            ':-)) ': 'images/Smiley_Happy.ico',
            ':-( ': 'images/Smiley_Sad.ico'
        }
        for tip, path in self.smileys.items():
            smiley = wx.Image(path, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
            button = buttons.GenBitmapTextButton(bkg,
                                                 -1,
                                                 smiley,
                                                 size=(30, 30))
            button.SetUseFocusIndicator(False)
            button.SetToolTipString(tip)
            button.Bind(wx.EVT_BUTTON, self.smiley)
            hbox2.Add(button, proportion=0, flag=wx.ALIGN_CENTER)

        hbox2.Add(self.input_area, proportion=5, flag=wx.LEFT, border=5)
        hbox2.Add(self.send_button, proportion=0, border=5)

        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add(self.chat_contents,
                 proportion=6,
                 flag=wx.EXPAND
                 | wx.ALL | wx.TE_MULTILINE,
                 border=5)
        vbox.Add(hbox2, proportion=0, flag=wx.EXPAND | wx.ALL, border=5)

        hbox = wx.BoxSizer()
        hbox.Add(vbox0, proportion=0, flag=wx.EXPAND | wx.ALL, border=5)
        hbox.Add(vbox, proportion=8, flag=wx.EXPAND | wx.ALL, border=5)

        bkg.SetSizer(hbox)

        # 绑定后台事件
        EVT_RESULT(self, self.read_message)

        # 关闭程序时,干点其他的清理工作
        self.Bind(wx.EVT_CLOSE, self.close_)

        self.stop_button.Enable(False)
        self.pre_message = None

        self.host = '192.168.200.116'
        self.port = 5005
Example #25
0
    def __init__(self, parent, id, title):
        no_resize = wx.DEFAULT_FRAME_STYLE & ~(wx.RESIZE_BORDER
                                               | wx.MAXIMIZE_BOX)
        wx.Frame.__init__(self,
                          parent,
                          id,
                          title,
                          size=(600, 600),
                          style=no_resize)

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.vbox = wx.BoxSizer(wx.VERTICAL)

        self.pLeft = scrolled.ScrolledPanel(self, -1, size=(360, 600))
        pRight = scrolled.ScrolledPanel(self, -1, size=(240, 600))
        self.SetBackgroundColour('#F2F2F2')
        self.pLeft.SetBackgroundColour('#F2F2F2')
        pRight.SetBackgroundColour('#D8D8D8')

        gs = wx.BoxSizer(wx.VERTICAL)

        gs.AddSpacer(30)
        self.stStation = wx.StaticText(pRight, -1, '')
        gs.Add(self.stStation, 0, wx.ALIGN_CENTER | wx.ALL, 0)

        self.btnSta = buttons.GenBitmapTextButton(
            pRight,
            -1,
            label=u" 终端接入",
            bitmap=wx.ArtProvider.GetBitmap(wx.ART_ADD_BOOKMARK),
            size=(160, 45))
        self.btnSta.Bind(wx.EVT_BUTTON, self.OnRegister)
        gs.Add(self.btnSta, 0, wx.ALIGN_CENTER | wx.ALL, 15)

        gs.AddSpacer(30)
        gs.Add(wx.StaticLine(pRight), 0, wx.ALL | wx.EXPAND, 5)
        gs.AddSpacer(30)

        self.stClock = wx.StaticText(pRight, -1, '')
        gs.Add(self.stClock, 0, wx.ALIGN_CENTER | wx.ALL, 0)

        self.btnCheckin = buttons.GenBitmapTextButton(
            pRight,
            -1,
            label=u" 员工签到",
            bitmap=wx.ArtProvider.GetBitmap(wx.ART_TICK_MARK),
            size=(160, 45))
        self.btnCheckin.Bind(wx.EVT_BUTTON, self.OnCheckin)
        gs.Add(self.btnCheckin, 0, wx.ALIGN_CENTER | wx.ALL, 15)

        gs.AddSpacer(30)
        gs.Add(wx.StaticLine(pRight), 0, wx.ALL | wx.EXPAND, 5)
        gs.AddSpacer(30)

        self.btnMsgs = buttons.GenBitmapTextButton(
            pRight,
            -1,
            label=u"本机消息",
            bitmap=wx.ArtProvider.GetBitmap(wx.ART_GO_HOME),
            size=(160, 45))
        self.btnMsgs.Bind(wx.EVT_BUTTON, self.OnMessages)
        gs.Add(self.btnMsgs, 0, wx.ALIGN_CENTER | wx.ALL, 15)

        self.btnPhones = buttons.GenBitmapTextButton(
            pRight,
            -1,
            label=u" 终端列表",
            bitmap=wx.ArtProvider.GetBitmap(wx.ART_LIST_VIEW),
            size=(160, 45))
        self.btnPhones.Bind(wx.EVT_BUTTON, self.OnPhones)
        gs.Add(self.btnPhones, 0, wx.ALIGN_CENTER | wx.ALL, 15)

        pRight.SetSizer(gs)
        pRight.Layout()
        self.pLeft.SetupScrolling()
        pRight.SetupScrolling()

        self.RenderUI()
        self.Notify()

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.onTimer, self.timer)
        self.timer.Start(5 * 60 * 1000)

        sizer.Add(self.pLeft, 1, wx.LEFT | wx.EXPAND, 0)
        sizer.Add(pRight, 1, wx.LEFT | wx.EXPAND, 0)
        self.SetSizer(sizer)
        self.Layout()
Example #26
0
    def __init__(self,
                 parent=None,
                 id=wx.ID_ANY,
                 title="SwitchHost!",
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.DEFAULT_FRAME_STYLE,
                 cls_TaskBarIcon=None):
        wx.Frame.__init__(self, parent, id, title, pos, size, style)

        self.SetIcon(co.GetMondrianIcon())
        self.taskbar_icon = cls_TaskBarIcon(self)
        #        self.Bind(wx.EVT_CLOSE, self.OnClose)
        self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize)

        self.m_menubar1 = wx.MenuBar(0)
        self.m_menu1 = wx.Menu()
        self.m_menuItem_new = wx.MenuItem(self.m_menu1, wx.ID_NEW, u"新建(&N)",
                                          wx.EmptyString, wx.ITEM_NORMAL)
        self.m_menu1.AppendItem(self.m_menuItem_new)
        self.m_menu1.AppendSeparator()
        self.m_menuItem_exit = wx.MenuItem(self.m_menu1, wx.ID_EXIT, u"退出(&X)",
                                           wx.EmptyString, wx.ITEM_NORMAL)
        self.m_menu1.AppendItem(self.m_menuItem_exit)

        self.m_menubar1.Append(self.m_menu1, u"文件(&F)")

        self.m_menu2 = wx.Menu()
        self.m_menuItem_about = wx.MenuItem(self.m_menu2, wx.ID_ABOUT,
                                            u"关于(&A)", wx.EmptyString,
                                            wx.ITEM_NORMAL)
        self.m_menu2.AppendItem(self.m_menuItem_about)

        self.m_menubar1.Append(self.m_menu2, u"帮助(&H)")

        self.SetMenuBar(self.m_menubar1)

        bSizer1 = wx.BoxSizer(wx.VERTICAL)

        self.m_panel1 = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition,
                                 wx.DefaultSize, wx.TAB_TRAVERSAL)
        bSizer4 = wx.BoxSizer(wx.HORIZONTAL)

        bSizer5 = wx.BoxSizer(wx.VERTICAL)

        self.m_list = wx.ListCtrl(self.m_panel1, wx.ID_ANY, wx.DefaultPosition,
                                  wx.Size(160, 320), wx.LC_REPORT)
        bSizer5.Add(self.m_list, 0, wx.ALL | wx.EXPAND, 5)

        bSizer61 = wx.BoxSizer(wx.HORIZONTAL)

        self.m_btn_add = buttons.GenBitmapTextButton(
            self.m_panel1, wx.ID_ADD, co.GetMondrianBitmap(fn="add"), u"添加")
        bSizer61.Add(self.m_btn_add, 0, wx.ALL, 5)

        self.m_btn_del = buttons.GenBitmapTextButton(
            self.m_panel1, wx.ID_DELETE, co.GetMondrianBitmap(fn="delete"),
            u"删除")
        bSizer61.Add(self.m_btn_del, 0, wx.ALL, 5)

        bSizer5.Add(bSizer61, 1, wx.EXPAND, 5)

        bSizer4.Add(bSizer5, 0, wx.EXPAND, 5)

        bSizer6 = wx.BoxSizer(wx.VERTICAL)

        self.m_textCtrl_content = wx.TextCtrl(
            self.m_panel1, self.ID_HOSTS_TEXT, wx.EmptyString,
            wx.DefaultPosition, wx.DefaultSize,
            wx.TE_MULTILINE | wx.TE_RICH2 | wx.TE_PROCESS_TAB | wx.HSCROLL)
        self.m_textCtrl_content.SetMaxLength(0)
        bSizer6.Add(self.m_textCtrl_content, 1, wx.ALL | wx.EXPAND, 5)

        bSizer7 = wx.BoxSizer(wx.HORIZONTAL)

        self.m_panel3 = wx.Panel(self.m_panel1, wx.ID_ANY, wx.DefaultPosition,
                                 wx.DefaultSize, wx.TAB_TRAVERSAL)
        bSizer71 = wx.BoxSizer(wx.HORIZONTAL)

        #        self.m_btn_save = buttons.GenBitmapTextButton(self.m_panel3, wx.ID_SAVE, co.GetMondrianBitmap(fn="disk"), u"保存")
        #        bSizer71.Add(self.m_btn_save, 0, wx.ALL, 0)

        self.m_panel3.SetSizer(bSizer71)
        self.m_panel3.Layout()
        bSizer71.Fit(self.m_panel3)
        bSizer7.Add(self.m_panel3, 1, wx.EXPAND | wx.ALL, 5)

        self.m_btn_apply = buttons.GenBitmapTextButton(
            self.m_panel1, wx.ID_APPLY, co.GetMondrianBitmap(fn="accept"),
            u"应用")
        #        self.m_btn_apply = wx.Button(self.m_panel1, wx.ID_APPLY, u"应用", wx.DefaultPosition, wx.DefaultSize, 0)
        bSizer7.Add(self.m_btn_apply, 0, wx.ALL, 5)

        if cls_TaskBarIcon and os.name == "nt":
            # ubuntu 10.04 下点击这个图标时会报错,图标的菜单无法正常工作
            # ubuntu 11.04 下这个图标总是无法显示
            # 由于跨平台问题,暂时决定只在 windows 下显示快捷的任务栏图标
            # 参见:http://stackoverflow.com/questions/7144756/wx-taskbaricon-on-ubuntu-11-04
            self.m_btn_exit = buttons.GenBitmapTextButton(
                self.m_panel1, wx.ID_CLOSE, co.GetMondrianBitmap(fn="door"),
                u"隐藏")
            #            self.m_btn_exit = wx.Button(self.m_panel1, wx.ID_CLOSE, u"隐藏", wx.DefaultPosition, wx.DefaultSize, 0)
            bSizer7.Add(self.m_btn_exit, 0, wx.ALL, 5)

        bSizer6.Add(bSizer7, 0, wx.EXPAND, 5)

        bSizer4.Add(bSizer6, 1, wx.EXPAND, 5)

        self.m_panel1.SetSizer(bSizer4)
        self.m_panel1.Layout()
        bSizer4.Fit(self.m_panel1)
        bSizer1.Add(self.m_panel1, 1, wx.EXPAND | wx.ALL, 0)

        self.SetSizer(bSizer1)
        self.Layout()

        self.Centre(wx.BOTH)

        self.font_bold = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
        self.font_bold.SetWeight(wx.BOLD)
        self.font_normal = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
        self.font_normal.SetWeight(wx.NORMAL)

        self.font_mono = wx.Font(10,
                                 wx.ROMAN,
                                 wx.NORMAL,
                                 wx.NORMAL,
                                 faceName="Courier New")
Example #27
0
    def __init__(self, parent, info_panel):
        wx.Panel.__init__(self, parent, -1)

        self.info_panel = info_panel
        self.btn_start = buttons.GenBitmapTextButton(self,
                                                     -1,
                                                     Resource.play,
                                                     u'启动',
                                                     style=wx.NO_BORDER)
        self.btn_pause = buttons.GenBitmapTextButton(self,
                                                     -1,
                                                     Resource.pause,
                                                     u'暂停',
                                                     style=wx.NO_BORDER)
        self.btn_resume = buttons.GenBitmapTextButton(self,
                                                      -1,
                                                      Resource.resume,
                                                      u'恢复',
                                                      style=wx.NO_BORDER)
        self.btn_shutdown = buttons.GenBitmapTextButton(self,
                                                        -1,
                                                        Resource.shutdown,
                                                        u'关闭',
                                                        style=wx.NO_BORDER)
        self.btn_reboot = buttons.GenBitmapTextButton(self,
                                                      -1,
                                                      Resource.reboot,
                                                      u'重启',
                                                      style=wx.NO_BORDER)
        self.btn_console = buttons.GenBitmapTextButton(self,
                                                       -1,
                                                       Resource.console,
                                                       u'连接桌面',
                                                       style=wx.NO_BORDER)
        self.btn_refresh = buttons.GenBitmapTextButton(self,
                                                       -1,
                                                       Resource.refresh,
                                                       u'全部刷新',
                                                       style=wx.NO_BORDER)

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(self.btn_start, 0, wx.ALIGN_CENTER_VERTICAL)
        sizer.AddSpacer(5)
        sizer.Add(self.btn_pause, 0, wx.ALIGN_CENTER_VERTICAL)
        sizer.AddSpacer(5)
        sizer.Add(self.btn_resume, 0, wx.ALIGN_CENTER_VERTICAL)
        sizer.AddSpacer(5)
        sizer.Add(self.btn_shutdown, 0, wx.ALIGN_CENTER_VERTICAL)
        sizer.AddSpacer(5)
        sizer.Add(self.btn_reboot, 0, wx.ALIGN_CENTER_VERTICAL)
        sizer.AddSpacer(5)
        sizer.AddSpacer(5)
        sizer.Add(self.btn_console, 0, wx.ALIGN_CENTER_VERTICAL)
        sizer.AddStretchSpacer()
        sizer.Add(self.btn_refresh, 0, wx.ALIGN_CENTER_VERTICAL)

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(sizer, 0, wx.EXPAND)

        self.vmlist = wx.ListCtrl(self,
                                  style=wx.LC_REPORT | wx.BORDER_SUNKEN
                                  | wx.LC_SINGLE_SEL)

        self.Bind(wx.EVT_BUTTON, self.OnRefresh, self.btn_refresh)
        mainSizer.AddSpacer(3)
        mainSizer.Add(self.vmlist, 1, wx.EXPAND)
        box = wx.StaticBox(self, -1, u"虚拟机视图")
        outSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        outSizer.Add(Util.CreateCenterSizer(mainSizer, 10), 1, flag=wx.EXPAND)
        self.SetSizer(outSizer)

        self.vmlist.AssignImageList(VM.GetStatusIconList(),
                                    wx.IMAGE_LIST_SMALL)
        self.vmlist.InsertColumn(0, u'', width=50)
        self.vmlist.InsertColumn(1, u'名称', width=300)
        self.vmlist.InsertColumn(2, u'状态', width=800)
        self.vms = None
        self.fps = None
        self.SetButtonStatus()
        self.refreshthread = None
        self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected, self.vmlist)
        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.onDCLICK, self.vmlist)
        self.Bind(wx.EVT_LIST_KEY_DOWN, self.OnKeyDown, self.vmlist)
        self.Bind(wx.EVT_BUTTON, self.OnStart, self.btn_start)
        self.Bind(wx.EVT_BUTTON, self.OnPause, self.btn_pause)
        self.Bind(wx.EVT_BUTTON, self.OnResume, self.btn_resume)
        self.Bind(wx.EVT_BUTTON, self.OnShutdown, self.btn_shutdown)
        self.Bind(wx.EVT_BUTTON, self.OnReboot, self.btn_reboot)
        #self.Bind(wx.EVT_BUTTON, self.OnStop, self.btn_stop)
        self.Bind(wx.EVT_BUTTON, self.OnConsole, self.btn_console)
        self.Bind(wx.EVT_WINDOW_DESTROY, self.OnWindowDestroy)

        # Now send refresh message
        evt = wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED,
                              self.btn_refresh.GetId())
        #self.refreshthread.refresh_all()
        #self.vmlist.Bind(wx.EVT_COMMAND_RIGHT_DCLICK, handler, source, id, id2)
        wx.PostEvent(self, evt)
        focusThread = FocusThread(self)
        focusThread.start()
    def OnPlaylistChecked(self, event):
        leftSizer = self._leftPanel.GetSizer()
        if leftSizer.GetItemCount() == 7:
            self._leftPanel.Freeze()
            leftSizer.Clear(True)

            colour = wx.Colour(145, 145, 145)

            bitmap = wx.Bitmap(os.path.join(bitmapDir, 'cancel.png'))
            cancelBtn = buttons.GenBitmapTextButton(self._leftPanel,
                                                    bitmap=bitmap,
                                                    label='  Cancel')
            cancelBtn.SetBackgroundColour(colour)
            cancelBtn.SetBezelWidth(0)
            cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel)

            leftSizer.Add(cancelBtn,
                          flag=wx.EXPAND | wx.TOP | wx.RIGHT,
                          proportion=1,
                          border=10)

            bitmap = wx.Bitmap(os.path.join(bitmapDir, 'add-to.png'))
            addSongsBtn = buttons.GenBitmapTextButton(self._leftPanel,
                                                      bitmap=bitmap,
                                                      label='  Add Songs')
            addSongsBtn.SetBackgroundColour(colour)
            addSongsBtn.SetBezelWidth(0)
            addSongsBtn.Bind(wx.EVT_BUTTON, self.OnAddSong)
            leftSizer.Add(addSongsBtn,
                          flag=wx.EXPAND | wx.TOP | wx.RIGHT,
                          proportion=1,
                          border=10)

            bitmap = wx.Bitmap(os.path.join(bitmapDir, 'delete.png'))
            deleteBtn = buttons.GenBitmapTextButton(self._leftPanel,
                                                    bitmap=bitmap,
                                                    label='  Delete')
            deleteBtn.SetBackgroundColour(colour)
            deleteBtn.SetBezelWidth(0)
            deleteBtn.Bind(wx.EVT_BUTTON, self.OnDelete)

            leftSizer.Add(deleteBtn,
                          flag=wx.EXPAND | wx.TOP | wx.RIGHT,
                          proportion=1,
                          border=10)

            bitmap = wx.Bitmap(os.path.join(bitmapDir, 'select-all.png'))
            selectAllBtn = buttons.GenBitmapTextToggleButton(
                self._leftPanel,
                bitmap=bitmap,
                size=(110, -1),
                label='  Select All')
            bitmap = wx.Bitmap(os.path.join(bitmapDir, 'deselect-all.png'))
            selectAllBtn.SetBitmapSelected(bitmap)
            selectAllBtn.SetBackgroundColour(colour)
            selectAllBtn.SetBezelWidth(0)
            selectAllBtn.Bind(wx.EVT_BUTTON, self.OnSelectDeselectAll)

            leftSizer.Add(selectAllBtn,
                          flag=wx.EXPAND | wx.ALL,
                          proportion=1,
                          border=10)

            self.GetSizer().Layout()
            self._leftPanel.Thaw()
Example #29
0
    def CreateTopControls(self):
        #协议树
        self.protobufTreeBtn = wx.Button(self, -1, u"协议树", size=(70, -1))

        #消息表
        self.msgIdBtn = wx.Button(self, -1, u"消息表", size=(70, -1))

        #网卡设置
        self.cardsetBtn = wx.Button(self, -1, u"网卡设置", size=(70, 40))

        # 输入框面板
        self.ipPortPanel = scrolled.ScrolledPanel(self,
                                                  size=(295, 105),
                                                  style=wx.TAB_TRAVERSAL)

        self.enabledArr = []
        self.inputTxtArr = []

        pDataLen = len(GenerateData.ProtobufData)
        for i in xrange(pDataLen):
            pData = GenerateData.ProtobufData[i]
            labelTxt = wx.TextCtrl(self.ipPortPanel,
                                   -1,
                                   pData["name"],
                                   size=(60, 22))
            ipTxt = wx.TextCtrl(self.ipPortPanel,
                                -1,
                                pData["ip"],
                                size=(100, 22))
            portTxt = wx.TextCtrl(self.ipPortPanel,
                                  -1,
                                  pData["port"],
                                  size=(50, 22))
            headlenTxt = wx.TextCtrl(self.ipPortPanel,
                                     -1,
                                     pData["headlen"],
                                     size=(25, 22))
            endianTxt = wx.TextCtrl(self.ipPortPanel,
                                    -1,
                                    pData["endian"],
                                    size=(20, 22))

            txtTuple = (labelTxt, ipTxt, portTxt, headlenTxt, endianTxt)
            self.inputTxtArr.append(txtTuple)
            self.enabledArr.extend(txtTuple)

        #过滤、启动、暂停 按钮
        self.wsCb = wx.CheckBox(self, -1, u"WS", size=(40, 24))
        self.processBtn = buttons.GenBitmapTextButton(
            self,
            -1,
            myImgs.AppPng.GetBitmap(),
            u"所有进程",
            size=(80, 24),
            style=wx.BORDER_NONE)
        self.filterBtn = wx.Button(self, -1, u"过滤", size=(120, -1))
        self.startBtn = wx.Button(self, -1, u"启动", size=(120, 35))

        self.wsCb.SetValue(False)
        self.filterBtn.Disable()
        self.startBtn.Disable()

        # 暂时隐藏
        self.wsCb.Hide()

        self.enabledArr.append(self.wsCb)
        self.enabledArr.append(self.filterBtn)
        self.enabledArr.append(self.cardsetBtn)
        self.enabledArr.append(self.processBtn)

        self.Bind(wx.EVT_BUTTON, self.OnProtobufTree, self.protobufTreeBtn)
        self.Bind(wx.EVT_BUTTON, self.OnMsgIdList, self.msgIdBtn)
        self.Bind(wx.EVT_BUTTON, self.OnCardSet, self.cardsetBtn)
        self.Bind(wx.EVT_BUTTON, self.OnFilter, self.filterBtn)
        self.Bind(wx.EVT_BUTTON, self.OnStartUp, self.startBtn)

        self.processBtn.Bind(wx.EVT_LEFT_DOWN, self.OnStartPickProcess)
        self.processBtn.Bind(wx.EVT_LEFT_UP, self.OnStopPickProcess)
        self.processBtn.Bind(wx.EVT_RIGHT_DOWN, self.OnClearCurrentProcess)

        sizer = wx.GridBagSizer(3, 3)

        sizer.Add(self.protobufTreeBtn, (0, 0))
        sizer.Add(self.msgIdBtn, (1, 0))
        sizer.Add(self.cardsetBtn, (2, 0))

        columnLen = 0
        if len(self.inputTxtArr) > 0:
            columnLen = len(self.inputTxtArr[0])
        scrollSizer = wx.GridBagSizer(pDataLen, columnLen)

        if columnLen > 0:
            for i in xrange(pDataLen):
                for j in xrange(columnLen):
                    scrollSizer.Add(self.inputTxtArr[i][j], (i, j))

        sizer.Add(self.ipPortPanel, (0, 1), (3, 1))

        wsSizer = wx.BoxSizer(wx.HORIZONTAL)
        wsSizer.Add(self.wsCb)
        wsSizer.Add(self.processBtn)

        sizer.Add(wsSizer, (0, 2))
        sizer.Add(self.filterBtn, (1, 2))
        sizer.Add(self.startBtn, (2, 2))

        self.ipPortPanel.SetSizer(scrollSizer)
        self.ipPortPanel.SetAutoLayout(1)
        self.ipPortPanel.SetupScrolling()
        self.SetSizer(sizer)

        return sizer
Example #30
0
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self,
                          parent,
                          id,
                          title,
                          style=wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX
                          | wx.SYSTEM_MENU | wx.FULL_REPAINT_ON_RESIZE)
        #Initialize proxy core
        self.core = proxycore.ProxyCore(Notifier(self))

        self.start_thread = None

        self.SetIcon(wx.Icon(WND_ICON, wx.BITMAP_TYPE_ICO))
        self.Bind(wx.EVT_CLOSE, self.on_close)

        self.out_panel = wx.Panel(self)

        simple_panel = wx.Panel(self.out_panel)
        self.simple_panel = simple_panel
        sizer_opts = wx.FlexGridSizer(rows=2, cols=2, vgap=10, hgap=5)
        sizer_opts.Add(wx.StaticText(simple_panel, label='Fetch Server:'),
                       flag=wx.EXPAND | wx.TOP,
                       border=3)
        self.servertext = wx.TextCtrl(simple_panel,
                                      value='your-appspot-id.appspot.com',
                                      size=(210, -1),
                                      style=wx.TE_PROCESS_ENTER)
        self.servertext.Bind(wx.EVT_TEXT_ENTER, self.OnEnterSubmit)
        sizer_opts.Add(self.servertext, flag=wx.EXPAND)
        sizer_opts.Add(wx.StaticText(simple_panel, label='Password:'******'',
                                   size=(210, -1),
                                   style=wx.TE_PASSWORD | wx.TE_PROCESS_ENTER)
        self.pwdtext.Bind(wx.EVT_SET_FOCUS, self.OnPwdFocus)
        self.pwdtext.Bind(wx.EVT_TEXT_ENTER, self.OnEnterSubmit)
        self.pwdfake = False
        sizer_pwd.Add(self.pwdtext, flag=wx.EXPAND | wx.BOTTOM, border=10)
        self.rememberchk = wx.CheckBox(simple_panel,
                                       label="Remember password.")
        sizer_pwd.Add(self.rememberchk, flag=wx.EXPAND)
        self.rememberchk.Bind(wx.EVT_CHECKBOX, self.OnCheckRememberPwd)
        sizer_pwd.Add(wx.StaticText(
            simple_panel,
            label="Do NOT check this if it's a public computer."),
                      flag=wx.TOP,
                      border=3)
        sizer_opts.Add(sizer_pwd, flag=wx.EXPAND)

        self.optbtn = bt.GenBitmapTextToggleButton(simple_panel,
                                                   -1,
                                                   bitmap=wx.Bitmap(OPT_ICON),
                                                   style=wx.NO_BORDER,
                                                   label='Options')
        self.optbtn.Bind(wx.EVT_BUTTON, self.OnToggleOptions)
        sizer_opts.Add(self.optbtn)

        sizer_start = wx.BoxSizer(wx.HORIZONTAL)
        sizer_start.Add(sizer_opts, flag=wx.EXPAND | wx.ALL, border=10)
        self.startbtn = bt.GenBitmapButton(simple_panel,
                                           -1,
                                           bitmap=wx.Bitmap(PLAY_ICON),
                                           size=(81, 81),
                                           style=wx.NO_BORDER)
        if wx.Platform != '__WXMSW__':
            #Some hack
            self.startbtn.SetBackgroundColour(COLOUR_NORMAL)
            self.startbtn.faceDnClr = COLOUR_NORMAL
        else:
            self.startbtn.faceDnClr = self.startbtn.GetBackgroundColour()
        self.startbtn.Bind(wx.EVT_BUTTON, self.OnStart)
        sizer_start.Add(self.startbtn, flag=wx.ALIGN_TOP | wx.ALL, border=10)

        sizer_out = wx.BoxSizer(wx.VERTICAL)
        sizer_out.Add(sizer_start, flag=wx.EXPAND | wx.ALL, border=10)

        simple_panel.SetSizer(sizer_out)

        adv_panel = wx.Panel(self.out_panel)
        self.adv_panel = adv_panel
        sizer_adv = wx.FlexGridSizer(rows=5, cols=2, vgap=10, hgap=5)

        sizer_adv.Add(wx.StaticText(adv_panel, label='Local Proxy:'),
                      flag=wx.EXPAND | wx.TOP,
                      border=3)
        sizer_proxy_out = wx.BoxSizer(wx.VERTICAL)
        self.proxycheck = wx.CheckBox(
            adv_panel, label='Check this if you are behind a proxy.')
        self.proxycheck.Bind(wx.EVT_CHECKBOX, self.on_check_proxy)
        sizer_proxy_out.Add(self.proxycheck, flag=wx.EXPAND | wx.TOP, border=5)
        sizer_proxy = wx.BoxSizer(wx.HORIZONTAL)
        sizer_proxy.Add(wx.StaticText(adv_panel, label='Host:'),
                        flag=wx.EXPAND | wx.TOP,
                        border=3)
        self.proxytext = wx.TextCtrl(adv_panel, value='', size=(160, -1))
        MyTipWindow(self,
                    self.proxytext,
                    text='Your local proxy. e.g. proxy.company.com')
        sizer_proxy.Add(self.proxytext,
                        flag=wx.EXPAND | wx.LEFT | wx.RIGHT,
                        border=5)
        sizer_proxy.Add(wx.StaticText(adv_panel, label='Port:'),
                        flag=wx.EXPAND | wx.TOP,
                        border=3)
        self.proxyporttext = nc.NumCtrl(adv_panel,
                                        id=-1,
                                        value=None,
                                        integerWidth=5,
                                        allowNone=True,
                                        limited=True,
                                        limitOnFieldChange=True,
                                        selectOnEntry=True,
                                        groupDigits=False,
                                        min=1,
                                        max=65535)
        MyTipWindow(self,
                    self.proxyporttext,
                    text='The port of the proxy. e.g. 8080')
        sizer_proxy.Add(self.proxyporttext,
                        flag=wx.EXPAND | wx.LEFT | wx.RIGHT,
                        border=5)

        sizer_proxy_out.Add(sizer_proxy, flag=wx.TOP, border=5)

        self.proxyauthcheck = wx.CheckBox(
            adv_panel, label='Check this if proxy requires authentication.')
        sizer_proxy_out.Add(self.proxyauthcheck,
                            flag=wx.EXPAND | wx.TOP,
                            border=5)
        self.proxyauthcheck.Bind(wx.EVT_CHECKBOX, self.on_check_proxy)
        sizer_auth = wx.BoxSizer(wx.HORIZONTAL)
        sizer_auth.Add(wx.StaticText(adv_panel, label='Username:'******'', size=(90, -1))
        sizer_auth.Add(self.proxyusertext,
                       flag=wx.EXPAND | wx.LEFT | wx.RIGHT,
                       border=5)
        sizer_auth.Add(wx.StaticText(adv_panel, label='Password:'******'',
                                        size=(90, -1),
                                        style=wx.TE_PASSWORD)
        sizer_auth.Add(self.proxypwdtext,
                       flag=wx.EXPAND | wx.LEFT | wx.RIGHT,
                       border=5)
        sizer_proxy_out.Add(sizer_auth, flag=wx.EXPAND | wx.TOP, border=5)

        sizer_adv.Add(sizer_proxy_out)

        sizer_adv.Add(wx.StaticText(adv_panel, label='Listen port:'),
                      flag=wx.EXPAND | wx.TOP,
                      border=3)
        self.porttext = nc.NumCtrl(adv_panel,
                                   id=-1,
                                   value=8000,
                                   limited=True,
                                   limitOnFieldChange=True,
                                   selectOnEntry=True,
                                   groupDigits=False,
                                   min=1,
                                   max=65535)
        MyTipWindow(
            self,
            self.porttext,
            text=
            'The local port Secure GAppProxy listens on. There\'re very few reasons to change this.\nPort number should be from 1 to 65535.'
        )
        sizer_adv.Add(self.porttext)

        sizer_adv.Add(wx.StaticText(adv_panel, label='Options:'),
                      flag=wx.EXPAND | wx.TOP,
                      border=3)
        sizer_advopts = wx.BoxSizer(wx.VERTICAL)
        self.httpschk = wx.CheckBox(adv_panel,
                                    label='Connect fetch server with HTTPS.')
        sizer_advopts.Add(self.httpschk, flag=wx.EXPAND | wx.BOTTOM, border=10)
        self.hostchk = wx.CheckBox(
            adv_panel,
            label='Try to detect and resolve connectivity issues on startup.')
        sizer_advopts.Add(self.hostchk, flag=wx.EXPAND | wx.BOTTOM, border=10)
        if wx.Platform == '__WXMSW__' and common.we_are_frozen():
            self.autostartchk = wx.CheckBox(adv_panel,
                                            label='Start proxy with Windows.')
            sizer_advopts.Add(self.autostartchk)
        sizer_adv.Add(sizer_advopts)

        ##sizer_adv.Add(wx.StaticText(adv_panel, label='Certificate:'), flag=wx.EXPAND | wx.TOP, border=3)
        ##sizer_certopts = wx.BoxSizer(wx.VERTICAL)
        ##self.clearcachebtn = wx.Button(adv_panel, label='Clear Certificate Cache')
        ##self.clearcachebtn.Bind(wx.EVT_BUTTON, self.on_clear_cert)
        ##sizer_certopts.Add(self.clearcachebtn)
        ##self.installcertbtn = wx.Button(adv_panel, label='Install Root Certificate')
        ##self.installcertbtn.Bind(wx.EVT_BUTTON, self.on_install_cert)
        ##sizer_certopts.Add(self.installcertbtn)
        ##sizer_adv.Add(sizer_certopts)

        sizer_adv_box = wx.BoxSizer(wx.VERTICAL)
        sizer_adv_box.Add(sizer_adv, flag=wx.EXPAND | wx.ALL, border=20)

        self.savebtn = wx.Button(adv_panel,
                                 size=(-1, 35),
                                 label='Save and Apply')
        self.savebtn.Bind(wx.EVT_BUTTON, self.OnSaveApply)
        sizer_adv_box.Add((-1, 30))
        sizer_adv_box.Add(self.savebtn,
                          flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.RIGHT,
                          border=20)

        adv_panel.SetSizer(sizer_adv_box)

        sizer_final = wx.BoxSizer(wx.VERTICAL)
        sizer_final.Add(simple_panel, flag=wx.EXPAND)
        sizer_final.Add(adv_panel, flag=wx.EXPAND)

        self.out_panel.SetSizer(sizer_final)

        MyTipWindow(
            self,
            self.servertext,
            text='Fetch server running on GAE. e.g. your-appspot-id.appspot.com'
        )

        self.min_size = sizer_out.GetMinSize().Get()
        w1, h1 = sizer_out.GetMinSize().Get()
        w2, h2 = sizer_adv_box.GetMinSize().Get()
        self.expand_size = (max(w1, w2), h1 + h2)
        self.Notify()

        self.Center()
        self.Show(True)
        self.startbtn.SetFocus()

        w, h = self.min_size
        self.statusbar = wx.Panel(simple_panel,
                                  style=wx.NO_BORDER,
                                  size=(300, 25),
                                  pos=(w - 300, h - 35))
        self.statustext = 'SecureGAppProxy is not running.'
        self.statusicon = wx.Bitmap(RED_ICON)
        self.statusbar.Bind(wx.EVT_PAINT, self.on_paint_status)
        self.statusbar.Refresh()

        self.about_btn = bt.GenBitmapTextButton(
            adv_panel,
            -1,
            bitmap=wx.Bitmap(ABOUTBTN_ICON),
            style=wx.NO_BORDER,
            label='About')

        self.about_btn.Bind(wx.EVT_BUTTON, self.on_about)
        if wx.Platform != '__WXMSW__':
            self.about_btn.SetBackgroundColour(COLOUR_NORMAL)
            self.about_btn.faceDnClr = COLOUR_NORMAL
        self.about_btn.SetBestSize((-1, -1))
        p1, p2 = adv_panel.GetClientRect().GetBottomLeft().Get()
        q1, q2 = self.about_btn.GetSizeTuple()
        self.about_btn.SetPosition((0, p2 - q2))

        if wx.Platform != '__WXMSW__':
            #Set background colour
            self.out_panel.SetBackgroundColour(COLOUR_NORMAL)
            simple_panel.SetBackgroundColour(COLOUR_NORMAL)
            adv_panel.SetBackgroundColour(COLOUR_NORMAL)
            self.statusbar.SetBackgroundColour(COLOUR_NORMAL)

        self.LoadConfig()

        #If we have the parameters needed, automatically connect
        if config.GetParam('password') != None and config.GetParam(
                'fetch_server') != '':
            self.OnStart(None)