Пример #1
0
    def createBaseGui(self):
        self.notesizer = wx.BoxSizer(wx.VERTICAL)
        # self.notebook = wx.Notebook(self.panel)
        # self.notebook = wx.Notebook(self.panel, style=wx.NB_LEFT)
        if os.name == "nt":
            self.notebook = wx.Notebook(self.panel, style=wx.BK_DEFAULT)
        else:
            self.notebook = wx.Notebook(
                self.panel,
                style=
                # wx.BK_DEFAULT
                # wx.BK_TOP
                # #wx.BK_BOTTOM
                wx.BK_LEFT
                # wx.BK_RIGHT
                #  | wx.NB_MULTILINE
            )

        # self.notebook.SetBackgroundColour(self.bgcolor)
        self.notebook.SetBackgroundColour("#FFFFFF")

        self.page0panel = self.newPanel(self.notebook)
        self.page1panel = self.newPanel(self.notebook)
        self.page2panel = self.newPanel(self.notebook)
        self.page3panel = self.newPanel(self.notebook)
        self.page4panel = self.newPanel(self.notebook)
        self.page5panel = self.newPanel(self.notebook)
        # self.page6panel = self.newPanel(self.notebook)

        # swyoo 2015.08.29 set color, image
        self.page0panel.SetBackgroundColour("#FFFFFF")
        self.page1panel.SetBackgroundColour("#FFFFFF")
        self.page2panel.SetBackgroundColour("#FFFFFF")
        self.page3panel.SetBackgroundColour("#FFFFFF")
        self.page4panel.SetBackgroundColour("#FFFFFF")
        # self.page5panel.SetBackgroundColour('#FFFFFF')

        # swyoo 2015.09.02 set background image
        image_file = "flexor/printing/printing_bg.png"
        bmp1 = wx.Image(imagefile(image_file), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        self.bitmap1 = wx.StaticBitmap(self.page1panel, -1, bmp1, (0, 0))

        image_file = "flexor/motor/motor_bg.png"
        bmp2 = wx.Image(imagefile(image_file), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        self.bitmap2 = wx.StaticBitmap(self.page2panel, -1, bmp2, (0, 0))

        # image_file = "flexor/setting/setting_bg.png"
        # bmp3 = wx.Image(imagefile(image_file), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        # self.bitmap3 = wx.StaticBitmap(self.page3panel, -1, bmp3, (0, 0))

        # font_loading_file = wx.Font(16, wx.MODERN, wx.NORMAL, wx.NORMAL, False, u'Consolas')
        self.font_14 = wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False, u"Consolas")
        self.font_16 = wx.Font(16, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False, u"Consolas")
        self.font_16_bold = wx.Font(16, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.BOLD)
        self.font_18 = wx.Font(18, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL, False)
        self.font_bold_20 = wx.Font(20, wx.DEFAULT, wx.NORMAL, wx.BOLD, False, u"Consolas")
        self.font_20 = wx.Font(20, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL, False)
        self.font_22 = wx.Font(22, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL)
        self.font_24 = wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL)
        self.font_26 = wx.Font(26, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL)
        self.font_28 = wx.Font(28, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL)
        self.font_32 = wx.Font(32, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False, u"Consolas")

        # ========================================================== tap0 : Home
        self.hometoolbarsizer = HomeToolbar(self, self.page0panel)
        self.page0panel.SetSizer(self.hometoolbarsizer)
        # ========================================================== tap1 : Print
        Print_Control(self, self.page1panel)
        # ========================================================== tap2 : Motor
        Motor_Control(self, self.page2panel)
        # ========================================================== tap3 : Setting
        # Setting_Control(self,  self.page3panel)
        # ========================================================== tap4 : help
        self.helptoolbarsizer = Setting_Help(self, self.page3panel)
        self.page4panel.SetSizer(self.helptoolbarsizer)
        # ========================================================== tap5 : Log
        # swyoo 2015.09.01 should pass VizPane for etc
        vizpane = VizPane(self, self.page4panel)

        self.mainsizer_4 = wx.BoxSizer(wx.HORIZONTAL)
        self.mainsizer_4.Add(LogPane(self, self.page4panel), 1, wx.EXPAND)
        self.page4panel.SetSizer(self.mainsizer_4)
        # ========================================================== tap6 : original
        if self.settings.uimode in (_("Tabbed"), _("Tabbed with platers")):
            createTabbedGui_sub(self, self.page5panel)
        else:
            createGui_sub(
                self, self.settings.uimode == _("Compact"), self.settings.controlsmode == "Mini", self.page5panel
            )
        # ========================================================== tap End
        self.notesizer.Add(self.notebook, 1, wx.EXPAND)
        self.notebook.AddPage(self.page0panel, _(""))
        self.notebook.AddPage(self.page1panel, _(""))
        self.notebook.AddPage(self.page2panel, _(""))
        self.notebook.AddPage(self.page3panel, _(""))
        if os.name == "nt":
            self.notebook.AddPage(self.page4panel, _("log"))
            self.notebook.AddPage(self.page5panel, _("Original"))

        # list containing notebook images:
        # .ico seem to be more OS portable
        il = wx.ImageList(102, 103)  # the (16, 16) is the size in pixels of the images

        self.img0 = il.Add(wx.Bitmap(imagefile("flexor/tap/tap_main.png"), wx.BITMAP_TYPE_PNG))
        self.img1 = il.Add(wx.Bitmap(imagefile("flexor/tap/tap_printing.png"), wx.BITMAP_TYPE_PNG))
        self.img2 = il.Add(wx.Bitmap(imagefile("flexor/tap/tap_control.png"), wx.BITMAP_TYPE_PNG))
        # self.img3 = il.Add(wx.Bitmap(imagefile("flexor/tap/tap_setting.png"), wx.BITMAP_TYPE_PNG))
        self.img3 = il.Add(wx.Bitmap(imagefile("flexor/tap/tap_help.png"), wx.BITMAP_TYPE_PNG))
        # self.img4 = il.Add(wx.Bitmap(imagefile("flexor/tap/tap_log.png"), wx.BITMAP_TYPE_PNG))
        # self.img5 = il.Add(wx.Bitmap(imagefile("flexor/tap/tap_original.png"), wx.BITMAP_TYPE_PNG))
        self.img0_ch = il.Add(wx.Bitmap(imagefile("flexor/tap/tap_main_ch.png"), wx.BITMAP_TYPE_PNG))
        self.img1_ch = il.Add(wx.Bitmap(imagefile("flexor/tap/tap_printing_ch.png"), wx.BITMAP_TYPE_PNG))
        self.img2_ch = il.Add(wx.Bitmap(imagefile("flexor/tap/tap_control_ch.png"), wx.BITMAP_TYPE_PNG))
        # self.img3_ch = il.Add(wx.Bitmap(imagefile("flexor/tap/tap_setting_ch.png"), wx.BITMAP_TYPE_PNG))
        self.img3_ch = il.Add(wx.Bitmap(imagefile("flexor/tap/tap_help_ch.png"), wx.BITMAP_TYPE_PNG))
        # self.img4_ch = il.Add(wx.Bitmap(imagefile("flexor/tap/tap_log_ch.png"), wx.BITMAP_TYPE_PNG))
        # self.img5_ch = il.Add(wx.Bitmap(imagefile("flexor/tap/tap_original_ch.png"), wx.BITMAP_TYPE_PNG))

        self.image_list = {
            0: self.img0,
            1: self.img1,
            2: self.img2,
            3: self.img3,
            4: self.img0_ch,
            5: self.img1_ch,
            6: self.img2_ch,
            7: self.img3_ch,
        }

        self.tap_list = {0: "home", 1: "print", 2: "motor", 3: "help"}

        # swyoo 2015.09.01 add to tap the image
        # set images to pages:
        # #first assign image list created above to notebook:
        self.notebook.AssignImageList(il)
        # then assign each image in list to corresponding page.
        # #the sharp-eyed will see you could use a loop for this,
        # #but for maximum clarity/understanding I'm using the long way...
        self.notebook.SetPageImage(0, self.img0_ch)
        self.notebook.SetPageImage(1, self.img1)
        self.notebook.SetPageImage(2, self.img2)
        self.notebook.SetPageImage(3, self.img3)
        # if os.name == "nt":
        #     self.notebook.SetPageImage(4, self.img4)
        #     self.notebook.SetPageImage(5, self.img5)

        # if this isn't called the notebook background color doesn't work right when switching
        #  themes in XP.
        self.notebook.SetBackgroundColour(self.notebook.GetThemeBackgroundColour())
        self.panel.SetSizer(self.notesizer)

        # swyoo 2015.11.17 should change tap image
        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.OnPageChanging)

        # self.panel.SetSizerAndFit(self.notesizer)
        self.Bind(wx.EVT_CLOSE, self.kill)
        minsize = [600, 450]
        self.SetMinSize(self.ClientToWindowSize(minsize))  # client to window
        self.Fit()
Пример #2
0
    def createBaseGui(self):
        self.notesizer = wx.BoxSizer(wx.VERTICAL)
        # self.notebook = wx.Notebook(self.panel)
        # self.notebook = wx.Notebook(self.panel, style=wx.NB_LEFT)
        if os.name == "nt":
            self.notebook = wx.Notebook(self.panel, style=wx.BK_DEFAULT)
        else:
            self.notebook = wx.Notebook(self.panel, style=
                                                    # wx.BK_DEFAULT
                                                    # wx.BK_TOP
                                                    # #wx.BK_BOTTOM
                                                    wx.BK_LEFT
                                                    # wx.BK_RIGHT
                                                    #  | wx.NB_MULTILINE
                                                    )

        # self.notebook.SetBackgroundColour(self.bgcolor)
        self.notebook.SetBackgroundColour('#E6E7E7')

        self.page0panel = self.newPanel(self.notebook)
        self.page1panel = self.newPanel(self.notebook)
        self.page2panel = self.newPanel(self.notebook)
        self.page3panel = self.newPanel(self.notebook)
        self.page4panel = self.newPanel(self.notebook)
        self.page5panel = self.newPanel(self.notebook)

        # swyoo 2015.08.29 set color, image
        self.page0panel.SetBackgroundColour('#E6E7E7')
        self.page1panel.SetBackgroundColour('#E6E7E7')
        self.page2panel.SetBackgroundColour('#E6E7E7')
        self.page3panel.SetBackgroundColour('#E6E7E7')
        # self.page4panel.SetBackgroundColour('#E6E7E7')
        # self.page5panel.SetBackgroundColour('#E6E7E7')

        # swyoo 2015.09.02 set background image
        image_file = 'flexor/print_bg.png'
        bmp1 = wx.Image(imagefile(image_file), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        self.bitmap1 = wx.StaticBitmap(self.page1panel, -1, bmp1, (0, 0))

        image_file = 'flexor/motor_bg.png'
        bmp2 = wx.Image(imagefile(image_file), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        self.bitmap2 = wx.StaticBitmap(self.page2panel, -1, bmp2, (0, 0))

        # image_file = 'flexor/setting_bg.png'
        # bmp3 = wx.Image(imagefile(image_file), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        # self.bitmap3 = wx.StaticBitmap(self.page3panel, -1, bmp3, (0, 0))

        # font_loading_file = wx.Font(16, wx.MODERN, wx.NORMAL, wx.NORMAL, False, u'Consolas')
        font_bold = wx.Font(20, wx.DEFAULT, wx.NORMAL, wx.BOLD, False, u'Consolas')
        self.font_gauge = wx.Font(30, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False, u'Consolas')
        if os.name == "nt":
            self.font_base = wx.Font(18, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL, False, u'Consolas')
        else:
            self.font_base = wx.Font(20, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL, False, u'Consolas')
        self.font_combo = wx.Font(16, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False, u'Consolas')

        self.font_big = wx.Font(20, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.BOLD, False)
        self.font_16 = wx.Font(16, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.BOLD)
        self.font_motor = wx.Font(26, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL)

        #========================================================== tap0 : Home
        self.hometoolbarsizer = HomeToolbar(self, self.page0panel)
        self.page0panel.SetSizer(self.hometoolbarsizer)
        #========================================================== tap1 : Print
        Print_Control(self, self.page1panel)
        #========================================================== tap2 : Motor
        Motor_Control(self, self.page2panel)
        #========================================================== tap3 : Setting
        Setting_Control(self,  self.page3panel)
        #========================================================== tap4 : Log
        # swyoo 2015.09.01 prevent 3d view for loading time in raspberry
        if 0:
            self.mainsizer = wx.BoxSizer(wx.HORIZONTAL)
            self.splitterwindow = wx.SplitterWindow(self.page4panel, style = wx.SP_3D)
            page4sizer1 = wx.BoxSizer(wx.HORIZONTAL)
            page4panel1 = self.newPanel(self.splitterwindow)

            page4sizer2 = wx.BoxSizer(wx.HORIZONTAL)
            page4panel2 = self.newPanel(self.splitterwindow)
            vizpane = VizPane(self, page4panel1)
            page4sizer1.Add(vizpane, 1, wx.EXPAND)
            page4sizer2.Add(LogPane(self, page4panel2), 1, wx.EXPAND)
            page4panel1.SetSizer(page4sizer1)
            page4panel2.SetSizer(page4sizer2)
            self.splitterwindow.SetMinimumPaneSize(1)
            self.splitterwindow.SetSashGravity(0.5)
            self.splitterwindow.SplitVertically(page4panel1, page4panel2,
                                                self.settings.last_sash_position)

            self.mainsizer.Add(self.splitterwindow, 1, wx.EXPAND)
            self.page4panel.SetSizer(self.mainsizer)
        else:
             # swyoo 2015.09.01 should pass VizPane for etc
            vizpane = VizPane(self, self.page4panel)

            self.mainsizer_4 = wx.BoxSizer(wx.HORIZONTAL)
            self.mainsizer_4.Add(LogPane(self, self.page4panel), 1, wx.EXPAND)
            self.page4panel.SetSizer(self.mainsizer_4)
        #========================================================== tap5 : Help
        if self.settings.uimode in (_("Tabbed"), _("Tabbed with platers")):
            createTabbedGui_sub(self, self.page5panel)
        else:
            createGui_sub(self, self.settings.uimode == _("Compact"),
                          self.settings.controlsmode == "Mini", self.page5panel)
        #========================================================== tap End
        self.notesizer.Add(self.notebook, 1, wx.EXPAND)
        if 0:
            self.notebook.AddPage(self.page0panel, _("Home"))
            self.notebook.AddPage(self.page1panel, _("Print"))
            self.notebook.AddPage(self.page2panel, _("Motor"))
            self.notebook.AddPage(self.page3panel, _("Setting"))
            self.notebook.AddPage(self.page4panel, _("Log.."))
            self.notebook.AddPage(self.page5panel, _("Original"))
        else:
            self.notebook.AddPage(self.page0panel, _(""))
            self.notebook.AddPage(self.page1panel, _(""))
            self.notebook.AddPage(self.page2panel, _(""))
            self.notebook.AddPage(self.page3panel, _(""))
            self.notebook.AddPage(self.page4panel, _(""))
            if os.name == "nt":
                self.notebook.AddPage(self.page5panel, _("Original"))

        # list containing notebook images:
        # .ico seem to be more OS portable
        il = wx.ImageList(107, 79) # the (16, 16) is the size in pixels of the images
        img0 = il.Add(wx.Bitmap(imagefile('flexor/menu/main.png'), wx.BITMAP_TYPE_PNG))
        img1 = il.Add(wx.Bitmap(imagefile('flexor/menu/print.png'), wx.BITMAP_TYPE_PNG))
        img2 = il.Add(wx.Bitmap(imagefile('flexor/menu/motor.png'), wx.BITMAP_TYPE_PNG))
        img3 = il.Add(wx.Bitmap(imagefile('flexor/menu/setting.png'), wx.BITMAP_TYPE_PNG))
        img4 = il.Add(wx.Bitmap(imagefile('flexor/menu/log.png'), wx.BITMAP_TYPE_PNG))
        # img5 = il.Add(wx.Bitmap(imagefile('flexor/menu/92p.png'), wx.BITMAP_TYPE_PNG))

        # swyoo 2015.09.01 add to tap the image
        # set images to pages:
        # #first assign image list created above to notebook:
        self.notebook.AssignImageList(il)
        # then assign each image in list to corresponding page.
        # #the sharp-eyed will see you could use a loop for this,
        # #but for maximum clarity/understanding I'm using the long way...
        self.notebook.SetPageImage(0, img0)
        self.notebook.SetPageImage(1, img1)
        self.notebook.SetPageImage(2, img2)
        self.notebook.SetPageImage(3, img3)
        self.notebook.SetPageImage(4, img4)
        # self.notebook.SetPageImage(5, img5)

        # if this isn't called the notebook background color doesn't work right when switching
        #  themes in XP.
        self.notebook.SetBackgroundColour(self.notebook.GetThemeBackgroundColour())
        self.panel.SetSizer(self.notesizer)
        # self.panel.SetSizerAndFit(self.notesizer)
        self.Bind(wx.EVT_CLOSE, self.kill)
        minsize = [600, 450]
        self.SetMinSize(self.ClientToWindowSize(minsize))  # client to window
        self.Fit()