예제 #1
0
파일: gui.py 프로젝트: MStopa/atbswp
    def __init__(self, *args, **kwds):
        """Build the interface."""
        if getattr(sys, 'frozen', False):
            self.path = sys._MEIPASS
        else:
            self.path = Path(__file__).parent.absolute()
        on_top = wx.DEFAULT_DIALOG_STYLE
        on_top = on_top if not settings.CONFIG.getboolean('DEFAULT', 'Always On Top') \
                        else on_top | wx.STAY_ON_TOP
        kwds["style"] = kwds.get("style", 0) | on_top
        wx.Dialog.__init__(self, *args, **kwds)
        self.panel = wx.Panel(self)
        self.icon = wx.Icon(os.path.join(self.path, "img", "icon.png"))
        self.SetIcon(self.icon)
        self.taskbar = TaskBarIcon(self)
        self.taskbar.SetIcon(self.icon, "atbswp")

        locale = self.__load_locale()
        self.app_text, self.settings_text = locale[:7], locale[7:]
        self.file_open_button = wx.BitmapButton(
            self, wx.ID_ANY,
            wx.Bitmap(os.path.join(self.path, "img", "file-upload.png"),
                      wx.BITMAP_TYPE_ANY))
        self.file_open_button.SetToolTip(self.app_text[0])
        self.save_button = wx.BitmapButton(
            self, wx.ID_ANY,
            wx.Bitmap(os.path.join(self.path, "img", "save.png"),
                      wx.BITMAP_TYPE_ANY))
        self.save_button.SetToolTip(self.app_text[1])
        self.record_button = wx.BitmapToggleButton(
            self, wx.ID_ANY,
            wx.Bitmap(os.path.join(self.path, "img", "video.png"),
                      wx.BITMAP_TYPE_ANY))
        self.record_button.SetToolTip(self.app_text[2])
        self.play_button = wx.BitmapToggleButton(
            self, wx.ID_ANY,
            wx.Bitmap(os.path.join(self.path, "img", "play-circle.png"),
                      wx.BITMAP_TYPE_ANY))
        self.play_button.SetToolTip(self.app_text[3])
        self.compile_button = wx.BitmapButton(
            self, wx.ID_ANY,
            wx.Bitmap(os.path.join(self.path, "img", "download.png"),
                      wx.BITMAP_TYPE_ANY))
        self.compile_button.SetToolTip(self.app_text[4])
        self.settings_button = wx.BitmapButton(
            self, wx.ID_ANY,
            wx.Bitmap(os.path.join(self.path, "img", "cog.png"),
                      wx.BITMAP_TYPE_ANY))
        self.settings_button.SetToolTip(self.app_text[5])

        self.help_button = wx.BitmapButton(
            self, wx.ID_ANY,
            wx.Bitmap(os.path.join(self.path, "img", "question-circle.png"),
                      wx.BITMAP_TYPE_ANY))
        self.help_button.SetToolTip(self.app_text[6])

        self.__add_bindings()
        self.__set_properties()
        self.__do_layout()
예제 #2
0
    def __init__(self, parent, main_window):
        self.parent = parent
        self.main_window = main_window
        self.tracker_panel = self.parent.GetParent()
        super(ZoomCtrl, self).__init__(parent)

        # Attributes
        self.move = 0
        self.chart_range = 100
        self.plot_zoom = False
        self.max_lock = False

        main_sizer = wx.GridBagSizer(5, 5)

        # Zoom checkbox
        btn_size = (32, 32)
        zoom_bmp = find_icon("zoom", size=24)
        self.btn_zoom = wx.BitmapToggleButton(self,
                                              label=zoom_bmp,
                                              size=btn_size)
        self.spn_zoom = ct.SpinCtrl(self,
                                    ctrl_size=(100, -1),
                                    ctrl_value=100,
                                    ctrl_min=10,
                                    ctrl_step=10)
        back_bmp = find_icon("back", size=24)
        self.btn_back = wx.BitmapButton(self, bitmap=back_bmp, size=btn_size)
        frwd_bmp = find_icon("forward", size=24)
        self.btn_frwd = wx.BitmapButton(self, bitmap=frwd_bmp, size=btn_size)
        xmax_bmp = find_icon("max", size=24)
        self.btn_lock = wx.BitmapToggleButton(self,
                                              label=xmax_bmp,
                                              size=btn_size)

        main_sizer.Add(self.btn_zoom, pos=(0, 0))
        main_sizer.Add(self.spn_zoom,
                       flag=wx.ALIGN_CENTER_VERTICAL,
                       pos=(0, 1))
        main_sizer.Add(self.btn_back, pos=(0, 2))
        main_sizer.Add(self.btn_frwd, pos=(0, 3))
        main_sizer.Add(self.btn_lock, pos=(0, 4))

        self.SetSizer(main_sizer)
        self.set_control()

        # button bindings
        self.btn_zoom.Bind(
            wx.EVT_TOGGLEBUTTON,
            self.onZoom,
        )
        self.spn_zoom.Bind(wx.EVT_SPINCTRL, self.onZoom)
        self.btn_back.Bind(wx.EVT_BUTTON, self.onBack)
        self.btn_frwd.Bind(wx.EVT_BUTTON, self.onFrwd)
        self.btn_lock.Bind(wx.EVT_TOGGLEBUTTON, self.onLock)
예제 #3
0
    def Buttons(self):
        self.FilterBtn = wx.Button(self.plbox,
                                   label="Filter",
                                   size=(100, 30),
                                   pos=(475, 453))

        choices = ['1', '2', '3', '4', '5']
        self.RatingBtns = wx.RadioBox(self.plbox,
                                      -1,
                                      "Rating",
                                      pos=(25, 440),
                                      size=(180, 45),
                                      choices=choices,
                                      style=wx.RA_HORIZONTAL)
        self.RatingBtns.SetForegroundColour((40, 40, 40))

        picPlayBtn = wx.Bitmap("play-button.png", wx.BITMAP_TYPE_ANY)
        picPlayBtn = self.scaleBitmap(picPlayBtn)

        picPrevBtn = wx.Bitmap("previous-song-button.png", wx.BITMAP_TYPE_ANY)
        picPrevBtn = self.scaleBitmap(picPrevBtn)

        picNextBtn = wx.Bitmap("next-song-button.png", wx.BITMAP_TYPE_ANY)
        picNextBtn = self.scaleBitmap(picNextBtn)

        picRepeatBtn = wx.Bitmap("repeat-button.png", wx.BITMAP_TYPE_ANY)
        picRepeatBtn = self.scaleBitmap(picRepeatBtn)

        self.ButtonPlay = wx.BitmapToggleButton(self.panel,
                                                label=picPlayBtn,
                                                pos=(325, 40))

        self.ButtonPrev = wx.BitmapButton(self.panel,
                                          bitmap=picPrevBtn,
                                          pos=(260, 40))

        self.ButtonNext = wx.BitmapButton(self.panel,
                                          bitmap=picNextBtn,
                                          pos=(390, 40))

        self.ButtonRepeat = wx.BitmapToggleButton(self.panel,
                                                  label=picRepeatBtn,
                                                  pos=(195, 40))

        self.ButtonPlay.Bind(wx.EVT_TOGGLEBUTTON, self.OnPlay)
        self.ButtonPrev.Bind(wx.EVT_BUTTON, self.OnPrev)
        self.ButtonNext.Bind(wx.EVT_BUTTON, self.OnNext)

        self.FilterBtn.Bind(wx.EVT_BUTTON, self.onFilter)
        self.RatingBtns.Bind(wx.EVT_RADIOBOX, self.onRate)
예제 #4
0
 def __init__(self, parent, bitmaps, *args, **kwargs):
     wx.Panel.__init__(self, parent, *args, **kwargs)
     self.SetBackgroundColour(wx.WHITE)
     layout = wx.BoxSizer(wx.HORIZONTAL)
     self.bitmap_buttons = [
         wx.BitmapToggleButton(self, -1, bitmap) for bitmap in bitmaps
     ]
     layout.AddMany(self.bitmap_buttons)
     self.SetSizer(layout)
예제 #5
0
def bitmap_button_creation(path, width, height, parent, position_x, position_y, toggle=False):
    # shortened button creation method
    bitmap = wx.Bitmap(path)
    image = bitmap.ConvertToImage()
    image = image.Scale(width, height, wx.IMAGE_QUALITY_HIGH)
    result = wx.Bitmap(image)
    if not toggle:
        button_created = wx.BitmapButton(parent, pos=(position_x, position_y), size=(height, width), bitmap=result)
    else:
        button_created = wx.BitmapToggleButton(parent, pos=(position_x, position_y), size=(height, width), label=result)
    return button_created
예제 #6
0
    def TreeItemChecked(self, event):
        
        def ScaleImage(img):
            # Resize image to geometry panel
            # NEEDS IMPROVEMENT TO BE MORE GENERAL (IN TERMS OF ASPECT RATIO)
            p_w, p_h   = self.geom_panel.GetSize()
            h          = img.GetHeight()
            w          = img.GetWidth()
            
            w_new = p_w*self.geom_tight/self.image_cols
            h_new = w_new*h/w
            img = img.Scale(w_new, h_new)

            return img
        
        
        
        # Get checked item and search for corresponding image
        #
        item = event.GetItem()
        id_  = self.ctc_dict_inv[item]
        
        self.selected_items = self.partTree_ctc.GetSelections()

        if item.IsChecked():
            # Get image
            if id_ in self.assembly.leaf_ids:
                img = self.assembly.tree_dict[id_]
                img = os.path.join('Images', img + '.png')
                if os.path.isfile(img):
                    img = wx.Image(img, wx.BITMAP_TYPE_ANY)
                else:
                    img = wx.Image(self.no_image_part, wx.BITMAP_TYPE_ANY)
            else:
                img = wx.Image(self.no_image_ass, wx.BITMAP_TYPE_ANY)
                
            # Create/add button in geom_panel
            # 
            # Includes rescaling to panel
            img = ScaleImage(img)
            button = wx.BitmapToggleButton(self.geom_panel, id_, wx.Bitmap(img))
            button.SetBackgroundColour('white')
            self.geom_sizer.Add(button, 0, wx.EXPAND)
            
            # Update global list and dict
            #
            # Data is list, i.e. same format as "selected_items"
            # but ctc lacks "get selections" method for checked items
            self.checked_items.append(item)
            self.button_dict[id_] = button
            self.button_dict_inv[button] = id_
            
            # Toggle if already selected elsewhere
            if self.ctc_dict[id_] in self.selected_items:
                button.SetValue(True)
            else:
                pass
            
        else:
            # Remove button from geom_panel
            obj = self.button_dict[id_]
            obj.Destroy()
            
            # Update global list and dict
            self.checked_items.remove(item)
            self.button_dict.pop(id_)
            self.button_dict_inv.pop(obj)
           
        # Update image sizer
        self.geom_sizer.Layout()
예제 #7
0
    def __init__(self, parent):
        wx.Frame.__init__(self,
                          parent=parent,
                          size=(1280, 720),
                          style=wx.SYSTEM_MENU)

        self.Center()

        background = wx.StaticBitmap(self)
        background.SetBitmap(
            wx.Bitmap(curWorkDir + "/pictures/move_background-v2.png"))

        # Buttons Pictures
        upArrow = wx.Image(curWorkDir + "/pictures/up_arrow.bmp",
                           wx.BITMAP_TYPE_BMP).ConvertToBitmap()
        downArrow = wx.Image(curWorkDir + "/pictures/down_arrow.bmp",
                             wx.BITMAP_TYPE_BMP).ConvertToBitmap()
        rightArrow = wx.Image(curWorkDir + "/pictures/right_arrow.bmp",
                              wx.BITMAP_TYPE_BMP).ConvertToBitmap()
        leftArrow = wx.Image(curWorkDir + "/pictures/left_arrow.bmp",
                             wx.BITMAP_TYPE_BMP).ConvertToBitmap()
        openBMP = wx.Image(curWorkDir + "/pictures/open_btn.bmp",
                           wx.BITMAP_TYPE_BMP).ConvertToBitmap()
        closeBMP = wx.Image(curWorkDir + "/pictures/close_btn.bmp",
                            wx.BITMAP_TYPE_BMP).ConvertToBitmap()

        # Buttons
        self.leftBtn_J2 = wx.BitmapToggleButton(background,
                                                -1,
                                                downArrow,
                                                pos=(705, 410))
        self.rightBtn_J2 = wx.BitmapToggleButton(background,
                                                 -1,
                                                 upArrow,
                                                 pos=(945, 410))
        self.leftBtn_J1 = wx.BitmapToggleButton(background,
                                                -1,
                                                leftArrow,
                                                pos=(705, 530))
        self.rightBtn_J1 = wx.BitmapToggleButton(background,
                                                 -1,
                                                 rightArrow,
                                                 pos=(945, 530))

        self.openBtn = wx.BitmapButton(background, -1, openBMP, pos=(705, 280))
        self.closeBtn = wx.BitmapButton(background,
                                        -1,
                                        closeBMP,
                                        pos=(940, 280))

        font2 = wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD)

        self.stopButton = wx.Button(background,
                                    label="Emergency Stop",
                                    pos=(1040, 20),
                                    size=(200, 50))
        self.stopButton.SetFont(font2)
        self.stopButton.SetFocus()

        ReturnHome = wx.Image(curWorkDir + "/pictures/Return_To_Home.bmp",
                              wx.BITMAP_TYPE_BMP).ConvertToBitmap()
        self.BtnReturnHome = wx.BitmapButton(
            background,
            -1,
            ReturnHome,
            pos=(30, 20),
        )

        # Font
        font = wx.Font(16, wx.MODERN, wx.NORMAL, wx.NORMAL, False, u'Consolas')

        # Text
        self.gripperTxt = wx.TextCtrl(background,
                                      value="OPEN",
                                      pos=(384, 282),
                                      size=(126, 43),
                                      style=wx.TE_READONLY | wx.TE_CENTER)
        self.motor1Txt = wx.TextCtrl(background,
                                     value=str(0),
                                     pos=(384, 548),
                                     size=(127, 43),
                                     style=wx.TE_READONLY | wx.TE_CENTER)
        self.motor2Txt = wx.TextCtrl(background,
                                     value=str(0),
                                     pos=(384, 415),
                                     size=(126, 43),
                                     style=wx.TE_READONLY | wx.TE_CENTER)
        self.gripperTxt.SetFont(font)
        self.motor1Txt.SetFont(font)
        self.motor2Txt.SetFont(font)

        # Setting up the menu.
        windowMenu = wx.Menu()
        menuAbout = windowMenu.Append(wx.ID_ABOUT, "&About",
                                      " Information about this window")

        # Creating the menubar.
        menuBar = wx.MenuBar()
        menuBar.Append(windowMenu, "&File")
        self.SetMenuBar(menuBar)

        # Events
        self.leftBtn_J2.Bind(wx.EVT_TOGGLEBUTTON, self.leftTurn_J2)
        self.rightBtn_J2.Bind(wx.EVT_TOGGLEBUTTON, self.rightTurn_J2)
        self.leftBtn_J1.Bind(wx.EVT_TOGGLEBUTTON, self.leftTurn_J1)
        self.rightBtn_J1.Bind(wx.EVT_TOGGLEBUTTON, self.rightTurn_J1)
        self.openBtn.Bind(wx.EVT_BUTTON, self.openBtnPressed)
        self.closeBtn.Bind(wx.EVT_BUTTON, self.closeBtnPressed)

        self.stopButton.Bind(wx.EVT_KEY_DOWN, self.emergencyStop)
        self.stopButton.Bind(wx.EVT_BUTTON, self.emergencyStop)

        self.Bind(wx.EVT_MENU, self.OnAbout, menuAbout)
        self.BtnReturnHome.Bind(wx.EVT_BUTTON, self.goToHome)

        self.Show()
예제 #8
0
    def __init__(self, parent):
        wx.Frame.__init__(self,
                          parent=parent,
                          size=(1280, 720),
                          style=wx.SYSTEM_MENU)

        self.Center()

        panel = wx.Panel(self)

        # Pictures
        titlePicture = wx.StaticBitmap(panel, pos=(320, 0))
        titlePicture.SetBitmap(
            wx.Bitmap(curWorkDir + "/pictures/recipe_window_title.png"))

        curPosTable = wx.StaticBitmap(panel, pos=(53, 130))
        curPosTable.SetBitmap(
            wx.Bitmap(curWorkDir + "/pictures/current_pos_table.png"))

        savedPosTable = wx.StaticBitmap(panel, pos=(448, 130))
        savedPosTable.SetBitmap(
            wx.Bitmap(curWorkDir + "/pictures/saved_pos_table.png"))

        moveRobotTable = wx.StaticBitmap(panel, pos=(843, 130))
        moveRobotTable.SetBitmap(
            wx.Bitmap(curWorkDir + "/pictures/move_robot_table.png"))

        # Buttons Pictures
        upArrow = wx.Image(curWorkDir + "/pictures/up_arrow.bmp",
                           wx.BITMAP_TYPE_BMP).ConvertToBitmap()
        downArrow = wx.Image(curWorkDir + "/pictures/down_arrow.bmp",
                             wx.BITMAP_TYPE_BMP).ConvertToBitmap()
        rightArrow = wx.Image(curWorkDir + "/pictures/right_arrow.bmp",
                              wx.BITMAP_TYPE_BMP).ConvertToBitmap()
        leftArrow = wx.Image(curWorkDir + "/pictures/left_arrow.bmp",
                             wx.BITMAP_TYPE_BMP).ConvertToBitmap()
        openBMP = wx.Image(curWorkDir + "/pictures/open_btn.bmp",
                           wx.BITMAP_TYPE_BMP).ConvertToBitmap()
        closeBMP = wx.Image(curWorkDir + "/pictures/close_btn.bmp",
                            wx.BITMAP_TYPE_BMP).ConvertToBitmap()

        savePosBMP = wx.Image(curWorkDir + "/pictures/save_pos_btn.bmp",
                              wx.BITMAP_TYPE_BMP).ConvertToBitmap()
        resetPosBMP = wx.Image(curWorkDir + "/pictures/reset_btn.bmp",
                               wx.BITMAP_TYPE_BMP).ConvertToBitmap()

        # Buttons
        self.openBtn = wx.BitmapButton(moveRobotTable,
                                       -1,
                                       openBMP,
                                       pos=(20, 130))
        self.closeBtn = wx.BitmapButton(moveRobotTable,
                                        -1,
                                        closeBMP,
                                        pos=(255, 130))
        self.leftBtn_J2 = wx.BitmapToggleButton(moveRobotTable,
                                                -1,
                                                downArrow,
                                                pos=(20, 255))
        self.rightBtn_J2 = wx.BitmapToggleButton(moveRobotTable,
                                                 -1,
                                                 upArrow,
                                                 pos=(255, 255))
        self.leftBtn_J1 = wx.BitmapToggleButton(moveRobotTable,
                                                -1,
                                                leftArrow,
                                                pos=(20, 380))
        self.rightBtn_J1 = wx.BitmapToggleButton(moveRobotTable,
                                                 -1,
                                                 rightArrow,
                                                 pos=(255, 380))

        self.savePosBtn = wx.BitmapButton(savedPosTable,
                                          -1,
                                          savePosBMP,
                                          pos=(190, 410))
        self.resetBtn = wx.BitmapButton(savedPosTable,
                                        -1,
                                        resetPosBMP,
                                        pos=(35, 155))

        font2 = wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD)
        self.BtnReturnHome = wx.Button(panel,
                                       label="Return to Home",
                                       pos=(30, 20),
                                       size=(200, 50))
        self.BtnReturnHome.SetFont(font2)

        self.stopButton = wx.Button(panel,
                                    label="Emergency Stop",
                                    pos=(1050, 20),
                                    size=(200, 50))
        self.stopButton.SetFont(font2)
        self.stopButton.SetFocus()

        # Drop Down Lists
        quantityChoices = ['0 Oz', '1 Oz', '2 Oz']
        self.quantityList = wx.Choice(savedPosTable,
                                      pos=(20, 425),
                                      size=(163, 200),
                                      choices=quantityChoices)
        font = wx.Font(16, wx.MODERN, wx.NORMAL, wx.NORMAL, False, u'Consolas')
        self.quantityList.SetFont(font)
        self.quantityList.SetSelection(0)

        # Text
        self.stateTxt = wx.TextCtrl(panel,
                                    value=state,
                                    pos=(624, 230),
                                    size=(173, 43),
                                    style=wx.TE_READONLY | wx.TE_CENTER)
        self.stateTxt.SetFont(font)

        self.gripperTxt = wx.TextCtrl(panel,
                                      value="OPEN",
                                      pos=(245, 274),
                                      size=(126, 43),
                                      style=wx.TE_READONLY | wx.TE_CENTER)
        self.gripperTxt.SetFont(font)

        self.motor1Txt = wx.TextCtrl(panel,
                                     value=str(0),
                                     pos=(245, 538),
                                     size=(126, 43),
                                     style=wx.TE_READONLY | wx.TE_CENTER)
        self.motor1Txt.SetFont(font)

        self.motor2Txt = wx.TextCtrl(panel,
                                     value=str(0),
                                     pos=(245, 406),
                                     size=(127, 43),
                                     style=wx.TE_READONLY | wx.TE_CENTER)
        self.motor2Txt.SetFont(font)

        # Setting up the menu.
        windowMenu = wx.Menu()
        menuAbout = windowMenu.Append(wx.ID_ABOUT, "&About",
                                      " Information about this window")

        # Creating the menubar.
        menuBar = wx.MenuBar()
        menuBar.Append(windowMenu, "&File")
        self.SetMenuBar(menuBar)

        # Events
        self.leftBtn_J2.Bind(wx.EVT_TOGGLEBUTTON, self.leftTurn_J2)
        self.rightBtn_J2.Bind(wx.EVT_TOGGLEBUTTON, self.rightTurn_J2)
        self.leftBtn_J1.Bind(wx.EVT_TOGGLEBUTTON, self.leftTurn_J1)
        self.rightBtn_J1.Bind(wx.EVT_TOGGLEBUTTON, self.rightTurn_J1)
        self.openBtn.Bind(wx.EVT_BUTTON, self.openBtnPressed)
        self.closeBtn.Bind(wx.EVT_BUTTON, self.closeBtnPressed)

        self.savePosBtn.Bind(wx.EVT_BUTTON, self.savePosBtnPressed)
        self.resetBtn.Bind(wx.EVT_BUTTON, self.resetPosBtnPressed)

        self.Bind(wx.EVT_MENU, self.OnAbout, menuAbout)
        self.BtnReturnHome.Bind(wx.EVT_BUTTON, self.goToHome)

        self.stopButton.Bind(wx.EVT_KEY_DOWN, self.emergencyStop)
        self.stopButton.Bind(wx.EVT_BUTTON, self.emergencyStop)

        self.Show()
예제 #9
0
    def __init__(self, *args, **kwgs):
        wx.Panel.__init__(self, *args, **kwgs)

        # current file and folder
        self.currentFile = ''
        self.currentDir = os.getcwd()

        # book control
        self.book = wx.Simplebook(self)

        # directory control
        self.ftree = wx.GenericDirCtrl(self.book,
                                       style=wx.DIRCTRL_EDIT_LABELS
                                       | wx.DIRCTRL_DIR_ONLY)

        # webview: flie list mode
        self.flist = html2.WebView.New(self.book)

        # webview: flie view mode
        # TODO: this will be replaced by proper viewer
        # wx.lib.ClickableHtmlWindow
        # wx.lib.docview
        # wx.lib.iewin
        # wx.lib.imagebrowser
        # wx.lib.imagebrowser.ImagePanel
        # wx.lib.pdfviewer
        # wx.lib.pdfwin
        # wx.lib.pydocview
        # textviewer
        # texteditor
        self.fview = html2.WebView.New(self.book)

        # button bitmaps
        bmpFTree = peiFTree.GetBitmap()
        bmpFList = peiFList.GetBitmap()
        bmpFView = peiFView.GetBitmap()
        bmpBMark = peiBMark.GetBitmap()
        #
        self.btnFTree = wx.BitmapToggleButton(
            self, -1, bmpFTree, (20, 20),
            (bmpFTree.GetWidth() + 14, bmpFTree.GetHeight() + 14))
        self.btnFList = wx.BitmapToggleButton(
            self, -1, bmpFList, (20, 20),
            (bmpFList.GetWidth() + 14, bmpFList.GetHeight() + 14))
        self.btnFView = wx.BitmapToggleButton(
            self, -1, bmpFView, (20, 20),
            (bmpFView.GetWidth() + 14, bmpFView.GetHeight() + 14))
        self.btnBMark = wx.BitmapButton(
            self, -1, bmpBMark, (20, 20),
            (bmpBMark.GetWidth() + 14, bmpBMark.GetHeight() + 14))
        #
        self.pages = [{
            'name': 'Tree',
            'page': self.ftree,
            'button': self.btnFTree
        }, {
            'name': 'List',
            'page': self.flist,
            'button': self.btnFList
        }, {
            'name': 'View',
            'page': self.fview,
            'button': self.btnFView
        }]

        # add pages to the book
        for idx, item in enumerate(self.pages):
            self.book.AddPage(item['page'], '')
            item['page no'] = idx

        # address bar
        self.bookmark = BookMark(self,
                                 -1,
                                 choices=[],
                                 style=wx.TE_PROCESS_ENTER)

        sizer_h = wx.BoxSizer(wx.HORIZONTAL)
        sizer_h.Add(self.btnFTree, 0, wx.ALL, 2)
        sizer_h.Add(self.btnFList, 0, wx.ALL, 2)
        sizer_h.Add(self.btnFView, 0, wx.ALL, 2)
        sizer_h.Add(self.bookmark, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2)
        sizer_h.Add(self.btnBMark, 0, wx.ALL, 2)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.book, 1, wx.ALL | wx.EXPAND, 4)
        sizer.Add(sizer_h, 0, wx.ALL | wx.EXPAND, 0)

        self.SetSizer(sizer)
        self.SetAutoLayout(True)
        sizer.Fit(self)

        # event from DIRCTRL
        self.Bind(wx.EVT_DIRCTRL_SELECTIONCHANGED, self.OnDirSelChanged,
                  self.ftree)
        self.Bind(wx.EVT_DIRCTRL_FILEACTIVATED, self.OnFileActivated,
                  self.ftree)

        # event from WEBVIEW
        self.Bind(wx.html2.EVT_WEBVIEW_NAVIGATED, self.OnWebNavigated,
                  self.flist)
        self.Bind(wx.html2.EVT_WEBVIEW_LOADED, self.OnWebLoaded, self.flist)

        # event from TOGGLEBUTTON
        self.Bind(wx.EVT_TOGGLEBUTTON, self.OnPageChange, self.btnFTree)
        self.Bind(wx.EVT_TOGGLEBUTTON, self.OnPageChange, self.btnFList)
        self.Bind(wx.EVT_TOGGLEBUTTON, self.OnPageChange, self.btnFView)
        # event from BUTTON
        self.Bind(wx.EVT_BUTTON, self.OnBookMark, self.btnBMark)

        # event from COMBOBOX
        self.Bind(wx.EVT_COMBOBOX, self.OnAddressSelect, self.bookmark)
        self.Bind(wx.EVT_TEXT_ENTER, self.OnAddressEnter, self.bookmark)

        # set initial page
        self.btnFTree.SetValue(1)
        self.SetCurrentPage('Tree')
예제 #10
0
    def __init__(self, parent):
        """Initialise widgets and layout."""
        super().__init__(parent=parent, title="Simulation")

        self.SetIcon(wx.Icon('GUI/CUED Software.png'))
        self.Maximize(True)
        self.SetBackgroundColour((186, 211, 255))
        self.parent = parent

        # Canvas for drawing signals
        self.canvas = Canvas(self, parent.devices, parent.monitors,
                             parent.network)
        self.Bind(wx.EVT_CLOSE, self.on_close)

        # Configure the widgets
        self.tostart = wx.Button(self, wx.ID_ANY, "GOTO START")
        self.tostart.name = 'start'
        self.tostart.Bind(wx.EVT_BUTTON, self.on_btn, self.tostart)
        self.back5 = wx.Button(self, wx.ID_ANY, "Step -5")
        self.back1 = wx.Button(self, wx.ID_ANY, "Step -1")
        play_pause = wx.Bitmap('GUI/Glyphicons/playpause.png')
        play_pause = scale_bitmap(play_pause, 25, 25)
        self.pause = wx.BitmapToggleButton(self, wx.ID_ANY, play_pause)
        self.fwd1 = wx.Button(self, wx.ID_ANY, "Step +1")
        self.fwd5 = wx.Button(self, wx.ID_ANY, "Step +5")
        self.toend = wx.Button(self, wx.ID_ANY, "GOTO END")
        self.toend.name = 'end'
        self.toend.Bind(wx.EVT_BUTTON, self.on_btn, self.toend)

        self.reset = wx.Button(self, wx.ID_ANY, "Reset Scene")
        self.reset.name = 'reset'
        self.reset.Bind(wx.EVT_BUTTON, self.on_btn, self.reset)

        # Configure sizers for layout
        main_sizer = wx.BoxSizer(wx.HORIZONTAL)
        left_sizer = wx.BoxSizer(wx.VERTICAL)
        toolbar = wx.GridSizer(9)
        right_sizer = wx.BoxSizer(wx.VERTICAL)

        main_sizer.Add(left_sizer, 5, wx.ALL | wx.EXPAND, 0)
        main_sizer.Add(right_sizer, 1, wx.ALL | wx.EXPAND, 5)

        left_sizer.Add(self.canvas, 100, wx.ALL | wx.EXPAND, 0)
        left_sizer.Add(toolbar, 0, wx.ALL | wx.EXPAND, 5)

        toolbar.Add(self.tostart, 1, wx.ALL | wx.ALIGN_LEFT | wx.EXPAND, 5)
        toolbar.AddSpacer(70)
        toolbar.Add(self.back5, 1, wx.ALL | wx.EXPAND | wx.ALIGN_RIGHT, 5)
        toolbar.Add(self.back1, 1, wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 5)
        toolbar.Add(self.pause, 1, wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 5)
        toolbar.Add(self.fwd1, 1, wx.ALL | wx.EXPAND | wx.ALIGN_CENTER, 5)
        toolbar.Add(self.fwd5, 1, wx.ALL | wx.EXPAND | wx.ALIGN_LEFT, 5)
        toolbar.AddSpacer(70)
        toolbar.Add(self.toend, 0, wx.ALL | wx.ALIGN_RIGHT | wx.EXPAND, 5)

        helpBtn = wx.Button(self, wx.ID_ANY, "Help")
        helpBtn.Bind(wx.EVT_BUTTON, self.open_help)
        right_sizer.Add(helpBtn, 0, wx.ALL | wx.ALIGN_RIGHT, 0)

        self.speedSizer = wx.Slider(self, value=30, minValue=5, maxValue=60)
        # right_sizer.Add(self.speedSizer, 0, wx.ALL|wx.GROW, 10)

        row = wx.BoxSizer(wx.HORIZONTAL)
        self.continueSpin = wx.SpinCtrl(self, wx.ID_ANY, "5")
        self.continueBtn = wx.Button(self, wx.ID_ANY, "Continue")
        self.continueBtn.name = "continue"
        self.continueBtn.Bind(wx.EVT_BUTTON, self.on_btn, self.continueBtn)

        right_sizer.AddSpacer(30)
        row.Add(self.continueSpin, 0, wx.ALL, 10)
        right_sizer.AddSpacer(30)
        row.Add(self.continueBtn, 0, wx.ALL, 10)
        right_sizer.Add(row, 0, wx.EXPAND, 10)
        right_sizer.AddSpacer(30)

        for device in self.parent.devices.devices_list:
            if device.device_kind == self.parent.devices.SWITCH:
                row = wx.BoxSizer(wx.HORIZONTAL)
                device.switch_btn = wx.ToggleButton(self, label="On/Off")
                device.switch_btn.name = 'switch ' + str(device.device_id)
                device.switch_btn.Bind(wx.EVT_TOGGLEBUTTON, self.on_btn,
                                       device.switch_btn)

                if device.switch_state == 1:
                    device.switch_btn.SetValue(True)

                row.Add(
                    wx.StaticText(self,
                                  0,
                                  label=self.parent.names.get_name_string(
                                      device.device_id)), 0,
                    wx.ALL | wx.ALIGN_CENTER_VERTICAL)
                row.AddSpacer(30)
                row.Add(device.switch_btn, 0, wx.ALL | wx.EXPAND)

                right_sizer.Add(row, 0, wx.ALIGN_CENTER)

        right_sizer.AddSpacer(30)
        right_sizer.Add(self.reset, 0, wx.EXPAND | wx.ALIGN_CENTER | wx.BOTTOM,
                        5)
        self.SetSizerAndFit(main_sizer)
예제 #11
0
    def __init__(self, parent, composer=False):
        wx.Panel.__init__(self, parent)
        self.parent = parent

        self.user_settings = self.parent.user_settings
        self.user_profile = self.parent.user_profile

        self.SetBackgroundColour(self.user_settings.get_background_color())
        self.emoji_categories = emoji_categs_from_file()
        if self.user_profile.username != "guest":
            self.emoji_categories["most_used"] = list(
                self.user_profile.used_emojis.keys())
        self.emoji_categ_buttons = dict()

        self.dbtab_sizer = wx.FlexGridSizer(3, 1, 0, 0)
        self.dbtab_sizer.AddGrowableRow(2)
        self.dbtab_sizer.AddGrowableCol(0)

        self.button_sizer = wx.GridSizer(1, len(self.emoji_categories), 0, 0)
        self.emoji_bmps_panel = wx.Panel()

        self.composer = composer

        self.dbtab_sizer.Add(self.button_sizer, 1, wx.EXPAND)
        self.dbtab_sizer.AddSpacer(10)
        if self.user_profile.username != "guest":
            mostused_bmp_file = os.path.join(
                os.path.abspath(os.path.dirname(__file__)), 'gui_utils_files',
                'most_used.png')
            most_used_bmp = wx.Bitmap(mostused_bmp_file).ConvertToImage()
            most_used_bmp = most_used_bmp.Scale(
                self.user_settings.get_composer_emoji_size()
                if self.composer else self.user_settings.get_db_emoji_size(),
                self.user_settings.get_composer_emoji_size()
                if self.composer else self.user_settings.get_db_emoji_size(),
                wx.IMAGE_QUALITY_HIGH)
            self.emoji_categ_buttons["most_used"] = wx.BitmapToggleButton(
                self,
                label=wx.Bitmap(most_used_bmp),
                name="most_used",
                style=wx.BORDER_NONE)
            self.emoji_categ_buttons["most_used"].Bind(wx.EVT_TOGGLEBUTTON,
                                                       self.OnEmojiCategory)
            self.emoji_categ_buttons["most_used"].SetCursor(
                wx.Cursor(wx.CURSOR_HAND))
            self.emoji_categ_buttons["most_used"].SetBackgroundColour(
                (255, 255, 255))
            self.button_sizer.Add(self.emoji_categ_buttons["most_used"], 1,
                                  wx.EXPAND)

        for cat in self.emoji_categories:
            if cat != "most_used":
                bmp_path = unicode_to_filename(
                    STRING_UNICODE[self.emoji_categories[cat][0]],
                    self.user_settings.get_composer_emoji_size() if
                    self.composer else self.user_settings.get_db_emoji_size())
                self.emoji_categ_buttons[cat] = wx.BitmapToggleButton(
                    self,
                    label=wx.Bitmap(bmp_path),
                    name=cat,
                    style=wx.BORDER_NONE)
                self.emoji_categ_buttons[cat].Bind(wx.EVT_TOGGLEBUTTON,
                                                   self.OnEmojiCategory)
                self.emoji_categ_buttons[cat].SetCursor(
                    wx.Cursor(wx.CURSOR_HAND))
                self.emoji_categ_buttons[cat].SetBackgroundColour(
                    (255, 255, 255))
                self.button_sizer.Add(self.emoji_categ_buttons[cat], 1,
                                      wx.EXPAND)

        self.SetSizer(self.dbtab_sizer)
예제 #12
0
        def __init__(self, parent, title):
            wx.Frame.__init__(self, parent, title=title)

            # tool panel
            self.pnlTool = wx.Panel(self)

            # controls
            # button bitmaps
            bmpFTree = peiFTree.GetBitmap()
            bmpFList = peiFList.GetBitmap()
            bmpFView = peiFView.GetBitmap()
            #
            self.btnFTree = wx.BitmapToggleButton(self.pnlTool, -1, bmpFTree,
                    (20,20), (bmpFTree.GetWidth()+8, bmpFTree.GetHeight()+8))
            self.btnFList = wx.BitmapToggleButton(self.pnlTool, -1, bmpFList,
                    (20,20), (bmpFList.GetWidth()+8, bmpFList.GetHeight()+8))
            self.btnFView = wx.BitmapToggleButton(self.pnlTool, -1, bmpFView,
                    (20,20), (bmpFView.GetWidth()+8, bmpFView.GetHeight()+8))
            self.cboAddr = PriorityCombo(self.pnlTool, size=(-1,28))
            self.cboAddr.AddItem("\\usr\\sjlee\\blahblah")

            # sizer
            sizer_x = wx.BoxSizer(wx.HORIZONTAL)
            sizer_x.Add(self.btnFTree, 0, wx.EXPAND|wx.TOP|wx.LEFT, 4)
            sizer_x.Add(self.btnFList, 0, wx.EXPAND|wx.TOP|wx.LEFT, 4)
            sizer_x.Add(self.btnFView, 0, wx.EXPAND|wx.TOP|wx.LEFT, 4)
            sizer_x.Add(self.cboAddr, 1,
                    wx.ALIGN_CENTER_VERTICAL|wx.TOP|wx.LEFT|wx.RIGHT, 4)
            self.pnlTool.SetSizer(sizer_x)

            # spliter window
            self.spw = wx.SplitterWindow(self, style=wx.SP_LIVE_UPDATE)
            self.spw.SetMinimumPaneSize(200)

            # main panel
            self.pnlFM1 = InnoFileMgr(self.spw)
            self.pnlFM2 = InnoFileMgr(self.spw)

            self.spw.SplitVertically(self.pnlFM1, self.pnlFM2, 0)

            # sizer
            sizer_y = wx.BoxSizer(wx.HORIZONTAL)
            sizer_y.Add(self.spw, 1, wx.EXPAND)

            # event binding
            self.Bind(wx.EVT_CLOSE, self.OnClose)
            self.Bind(wx.EVT_TOGGLEBUTTON, self.OnChangeView, self.btnFTree)
            self.Bind(wx.EVT_TOGGLEBUTTON, self.OnChangeView, self.btnFList)
            self.Bind(wx.EVT_TOGGLEBUTTON, self.OnChangeView, self.btnFView)
            self.pnlFM1.Bind(wx.EVT_CHAR_HOOK, self.OnCharFM1)
            self.pnlFM2.Bind(wx.EVT_CHAR_HOOK, self.OnCharFM2)

            sizer_z = wx.BoxSizer(wx.VERTICAL)
            sizer_z.Add(self.pnlTool, 0, wx.EXPAND)
            sizer_z.Add(sizer_y, 1, wx.EXPAND)

            self.SetSizer(sizer_z)
            self.SetAutoLayout(1)
            #sizer.Fit(self)
            self.SetSize((1200,800))
            self.Show()