예제 #1
0
    def init_ui(self):
        self.task_bar_icon = TaskBarIcon(self)
        self.Bind(wx.adv.EVT_TASKBAR_CLICK, self.on_task_bar_left_dclick)
        panel = wx.Panel(self)
        sizer = wx.GridBagSizer(0, 0)
        font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
        font.PointSize = 16
        self.SetFont(font)

        download_url = wx.StaticText(panel, label="游戏文件下载地址:")
        download_url.SetFont(font)
        sizer.Add(download_url, pos=(0, 0), flag=wx.ALL, border=10)

        self.tc1 = wx.TextCtrl(panel, style=wx.TE_MULTILINE | wx.TE_READONLY)
        sizer.Add(self.tc1, pos=(0, 1), flag=wx.EXPAND | wx.ALL, border=5)

        sizer.AddGrowableCol(1)
        sizer.AddGrowableRow(0)

        panel.SetSizerAndFit(sizer)

        hint_msg = wx.StaticText(panel, size=(200, 100), label="提示:\r通过第三方下载工具将文件下载至\r/Users/{}/Downloads".format(getpass.getuser()))
        sizer.Add(hint_msg, pos=(0, 2), flag=wx.ALL, border=5)

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_timer, self.timer)
        self.timer.Start(500)

        self.Bind(wx.EVT_CLOSE, self.on_exit)

        self.statusbar = self.CreateStatusBar()
        self.statusbar.SetFieldsCount(2)
        self.SetStatusWidths([-1, 330])
        self.statusbar.SetStatusText('Starting proxy server on {} port {}'.format(IP, PORT), 0)
예제 #2
0
    def layoutComponent(self):
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.header, 0, wx.EXPAND)
        sizer.Add(wx_util.horizontal_rule(self), 0, wx.EXPAND)

        sizer.Add(self.navbar, 1, wx.EXPAND)
        sizer.Add(self.console, 1, wx.EXPAND)
        sizer.Add(wx_util.horizontal_rule(self), 0, wx.EXPAND)
        sizer.Add(self.footer, 0, wx.EXPAND)
        self.SetMinSize((400, 300))
        self.SetSize(self.buildSpec['default_size'])
        self.SetSizer(sizer)
        self.console.Hide()
        self.Layout()
        if self.buildSpec.get('fullscreen', True):
            self.ShowFullScreen(True)
        # Program Icon (Windows)
        icon = wx.Icon(self.buildSpec['images']['programIcon'],
                       wx.BITMAP_TYPE_PNG)
        self.SetIcon(icon)
        if sys.platform != 'win32':
            # OSX needs to have its taskbar icon explicitly set
            # bizarrely, wx requires the TaskBarIcon to be attached to the Frame
            # as instance data (self.). Otherwise, it will not render correctly.
            self.taskbarIcon = TaskBarIcon(iconType=wx.adv.TBI_DOCK)
            self.taskbarIcon.SetIcon(icon)
예제 #3
0
    def __init__(self, parent, log):

        wx.Frame.__init__(self, parent, title="BalloonTip wxPython Demo ;-)")

        self.statusbar = self.CreateStatusBar(2)
        self.statusbar.SetStatusWidths([-2, -1])
        # statusbar fields
        statusbar_fields = [("Welcome To WxPython " + wx.VERSION_STRING),
                            ("BalloonTip Demo")]

        for i in range(len(statusbar_fields)):
            self.statusbar.SetStatusText(statusbar_fields[i], i)

        self.SetIcon(images.Mondrian.GetIcon())
        self.SetMenuBar(self.CreateMenuBar())

        panel = wx.Panel(self, -1)

        mainsizer = wx.FlexGridSizer(3, 4, hgap=2, vgap=2)

        # Add A Button
        button = wx.Button(panel, -1, "Press Me!")
        # Add A TextCtrl
        textctrl = wx.TextCtrl(panel, -1, "I Am A TextCtrl")
        # Add A CheckBox
        checkbox = wx.CheckBox(panel,
                               -1,
                               "3-State Checkbox",
                               style=wx.CHK_3STATE
                               | wx.CHK_ALLOW_3RD_STATE_FOR_USER)
        samplelist = [
            'One', 'Two', 'Three', 'Four', 'Kick', 'The', 'Demo', 'Out', 'The',
            'Door', ';-)'
        ]
        # Add A Choice
        choice = wx.Choice(panel, -1, choices=samplelist)
        # Add A Gauge
        gauge = wx.Gauge(panel, -1, 50, style=wx.GA_SMOOTH)
        # Add A ListBox
        listbox = wx.ListBox(panel, -1, choices=samplelist, style=wx.LB_SINGLE)
        # Add A TreeCtrl
        isz = (16, 16)
        treecontrol = wx.TreeCtrl(panel, -1)
        il = wx.ImageList(isz[0], isz[1])
        fldridx = il.Add(
            wx.ArtProvider.GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, isz))
        fldropenidx = il.Add(
            wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, isz))
        fileidx = il.Add(
            wx.ArtProvider.GetBitmap(wx.ART_REPORT_VIEW, wx.ART_OTHER, isz))
        treecontrol.SetImageList(il)
        self.il = il
        root = treecontrol.AddRoot("ROOT")
        treecontrol.SetItemData(root, None)
        treecontrol.SetItemImage(root, fldridx, wx.TreeItemIcon_Normal)
        treecontrol.SetItemImage(root, fldropenidx, wx.TreeItemIcon_Expanded)
        for ii in range(11):
            child = treecontrol.AppendItem(root, samplelist[ii])
            treecontrol.SetItemData(child, None)
            treecontrol.SetItemImage(child, fldridx, wx.TreeItemIcon_Normal)
            treecontrol.SetItemImage(child, fldropenidx,
                                     wx.TreeItemIcon_Selected)

        # Add A Slider
        slider = wx.Slider(panel,
                           -1,
                           25,
                           1,
                           100,
                           style=wx.SL_HORIZONTAL
                           | wx.SL_AUTOTICKS)  # | wx.SL_LABELS)
        slider.SetTickFreq(5)
        # Add Another TextCtrl
        textctrl2 = wx.TextCtrl(panel, -1, "Another TextCtrl")
        # Add A GenStaticText
        statictext = StaticText(panel, -1, "Hello World!")
        statictext.SetFont(
            wx.Font(9, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL,
                    wx.FONTWEIGHT_BOLD, False))
        bmp = wx.ArtProvider.GetBitmap(wx.ART_INFORMATION, wx.ART_TOOLBAR,
                                       (16, 16))
        # Add A GenBitmapButton
        bitmapbutton = BitmapButton(panel, -1, bmp)
        button2 = wx.Button(panel, -1, "Disable BalloonTip")

        tbicon = TaskBarIcon()
        tbicon.SetIcon(images.Mondrian.GetIcon())

        controls = list(panel.GetChildren())
        controls.append(tbicon)
        self.tbicon = tbicon

        # Add The Controls To The Main FlexGridSizer
        mainsizer.Add(button, 0, wx.EXPAND | wx.ALL, 10)
        mainsizer.Add(textctrl, 0, wx.EXPAND | wx.ALL, 10)
        mainsizer.Add(checkbox, 0, wx.EXPAND | wx.ALL, 10)
        mainsizer.Add(choice, 0, wx.EXPAND | wx.ALL, 10)
        mainsizer.Add(gauge, 0, wx.ALL, 10)
        mainsizer.Add(listbox, 0, wx.EXPAND | wx.ALL, 10)
        mainsizer.Add(treecontrol, 0, wx.EXPAND, wx.ALL, 10)
        mainsizer.Add(slider, 0, wx.ALL, 10)
        mainsizer.Add(textctrl2, 0, wx.ALL, 10)
        mainsizer.Add(statictext, 0, wx.EXPAND | wx.ALIGN_CENTER | wx.ALL, 10)
        mainsizer.Add(bitmapbutton, 0, wx.ALL, 10)
        mainsizer.Add(button2, 0, wx.ALL, 10)

        panel.SetSizer(mainsizer)
        mainsizer.Layout()

        # Declare The BalloonTip Background Colours
        bgcolours = [
            None, wx.WHITE, wx.GREEN, wx.BLUE, wx.CYAN, wx.RED, None, None,
            wx.LIGHT_GREY, None, wx.WHITE, None, None
        ]

        # Declare The BalloonTip Top-Left Icons
        icons = []
        for ii in range(4):
            bmp = wx.ArtProvider.GetBitmap(eval(ArtIDs[ii]), wx.ART_TOOLBAR,
                                           (16, 16))
            icons.append(bmp)

        icons.extend([None] * 5)

        for ii in range(4, 9):
            bmp = wx.ArtProvider.GetBitmap(eval(ArtIDs[ii]), wx.ART_TOOLBAR,
                                           (16, 16))
            icons.append(bmp)

        # Declare The BalloonTip Top Titles
        titles = [
            "Button Help", "Texctrl Help", "CheckBox Help", "Choice Help",
            "Gauge Help", "", "", "Read Me Carefully!", "SpinCtrl Help",
            "StaticText Help", "BitmapButton Help", "Button Help",
            "Taskbar Help"
        ]

        fontone = wx.Font(9, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL,
                          wx.FONTWEIGHT_BOLD, True)
        fonttwo = wx.Font(14, wx.FONTFAMILY_SCRIPT, wx.FONTSTYLE_NORMAL,
                          wx.FONTWEIGHT_BOLD, False)
        fontthree = wx.Font(9, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_ITALIC,
                            wx.FONTWEIGHT_NORMAL, False)
        fontfour = wx.Font(8, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL,
                           wx.FONTWEIGHT_BOLD, True)

        # Declare The BalloonTip Top Titles Fonts
        titlefonts = [
            None, None, fontone, None, fonttwo, fontthree, None, None, None,
            fontfour, fontthree, None, None
        ]

        # Declare The BalloonTip Top Titles Colours
        titlecolours = [
            None, None, wx.WHITE, wx.YELLOW, None, wx.WHITE, wx.BLUE, wx.RED,
            None, None, wx.LIGHT_GREY, None, None
        ]

        # Declare The BalloonTip Messages
        msg1 = "This Is The Default BalloonTip Window\nYou Can Customize It! "\
               "Look At The Demo!"
        msg2 = "You Can Change The Background Colour\n Of The Balloon Window."
        msg3 = "You Can Also Change The Font And The\nColour For The Title."
        msg4 = "I Have Nothing Special To Suggest!\n\nWelcome To wxPython " + \
               wx.VERSION_STRING + " !"
        msg5 = "What About If I Don't Want The Icon?\nNo Problem!"
        msg6 = "I Don't Have The Icon Nor The Title.\n\nDo You Love Me Anyway?"
        msg7 = "Some Comments On The Window Shape:\n\n- BT_ROUNDED: Creates A "\
               "Rounded Rectangle;\n- BT_RECTANGLE: Creates A Rectangle.\n"
        msg8 = "Some Comments On The BalloonTip Style:\n\n"\
               "BT_LEAVE: The BalloonTip Is Destroyed When\nThe Mouse Leaves"\
               "The Target Widget;\n\nBT_CLICK: The BalloonTip Is Destroyed When\n"\
               "You Click Any Region Of The BalloonTip;\n\nBT_BUTTON: The BalloonTip"\
               " Is Destroyed When\nYou Click On The Top-Right Small Button."
        msg9 = "Some Comments On Delay Time:\n\nBy Default, The Delay Time After Which\n"\
               "The BalloonTip Is Destroyed Is Very Long.\nYou Can Change It By Using"\
               " The\nSetEndDelay() Method."
        msg10 = "I Have Nothing Special To Suggest!\n\nRead Me FAST, You Have Only 3 "\
                "Seconds!"
        msg11 = "I Hope You Will Enjoy BalloonTip!\nIf This Is The Case, Please\n"\
                "Post Some Comments On wxPython\nMailing List!"
        msg12 = "This Button Enable/Disable Globally\nThe BalloonTip On Your Application."
        msg13 = "This Is A BalloonTip For The\nTaskBar Icon Of Your Application.\n"\
                "All The Styles For BalloonTip Work."

        messages = [
            msg1, msg2, msg3, msg4, msg5, msg6, msg7, msg8, msg9, msg10, msg11,
            msg12, msg13
        ]

        # Declare The BalloonTip Tip Messages Colours
        messagecolours = [
            None, None, None, wx.WHITE, wx.BLUE, None, wx.BLUE, None, None,
            wx.RED, wx.GREEN, wx.BLUE, None
        ]

        fontone = wx.Font(8, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL,
                          wx.FONTWEIGHT_NORMAL, True)
        fonttwo = wx.Font(8, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_ITALIC,
                          wx.FONTWEIGHT_NORMAL, False)
        fontthree = wx.Font(8, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL,
                            wx.FONTWEIGHT_BOLD, True)

        # Declare The BalloonTip Tip Messages Fonts
        messagefonts = [
            None, None, None, fontone, None, None, fonttwo, None, fontthree,
            None, None, None, None
        ]

        # Declare The BalloonTip Frame Shapes
        windowshapes = [
            BT.BT_ROUNDED, BT.BT_RECTANGLE, BT.BT_ROUNDED, BT.BT_RECTANGLE,
            BT.BT_ROUNDED, BT.BT_RECTANGLE, BT.BT_ROUNDED, BT.BT_ROUNDED,
            BT.BT_ROUNDED, BT.BT_RECTANGLE, BT.BT_ROUNDED, BT.BT_RECTANGLE,
            BT.BT_RECTANGLE
        ]

        # Declare The BalloonTip Destruction Style
        tipstyles = [
            BT.BT_LEAVE, BT.BT_CLICK, BT.BT_BUTTON, BT.BT_LEAVE, BT.BT_CLICK,
            BT.BT_LEAVE, BT.BT_CLICK, BT.BT_BUTTON, BT.BT_BUTTON, BT.BT_CLICK,
            BT.BT_LEAVE, BT.BT_LEAVE, BT.BT_BUTTON
        ]

        # Set The Targets/Styles For The BalloonTip
        for ii, widget in enumerate(controls):
            tipballoon = BT.BalloonTip(topicon=icons[ii],
                                       toptitle=titles[ii],
                                       message=messages[ii],
                                       shape=windowshapes[ii],
                                       tipstyle=tipstyles[ii])
            # Set The Target
            tipballoon.SetTarget(widget)
            # Set The Balloon Colour
            tipballoon.SetBalloonColour(bgcolours[ii])
            # Set The Font For The Top Title
            tipballoon.SetTitleFont(titlefonts[ii])
            # Set The Colour For The Top Title
            tipballoon.SetTitleColour(titlecolours[ii])
            # Set The Font For The Tip Message
            tipballoon.SetMessageFont(messagefonts[ii])
            # Set The Colour For The Tip Message
            tipballoon.SetMessageColour(messagecolours[ii])
            # Set The Delay After Which The BalloonTip Is Created
            tipballoon.SetStartDelay(1000)
            if ii == 9:
                # Set The Delay After Which The BalloonTip Is Destroyed
                tipballoon.SetEndDelay(3000)

        # Store The Last BalloonTip Reference To Enable/Disable Globall The
        # BalloonTip. You Can Store Any Of Them, Not Necessarily The Last One.
        self.lasttip = tipballoon
        self.gauge = gauge
        self.count = 0

        button2.Bind(wx.EVT_BUTTON, self.OnActivateBalloon)
        self.Bind(wx.EVT_IDLE, self.IdleHandler)

        frameSizer = wx.BoxSizer(wx.VERTICAL)
        frameSizer.Add(panel, 1, wx.EXPAND)
        self.SetSizer(frameSizer)
        frameSizer.Layout()
        self.Fit()

        self.CenterOnParent()
    def __init__(self, properties=None, parent=None, id=ID_IMAGE_GALLERY, **kwargs):

        if properties is not None:
            global p
            p = properties
            global db
            db = dbconnect.DBConnect()

        wx.Frame.__init__(self, parent, id=id, title='CPA/ImageGallery - %s' % \
                                                     (os.path.basename(p._filename)), size=(800, 600), **kwargs)
        if parent is None and not sys.platform.startswith('win'):
            from wx.adv import TaskBarIcon
            self.tbicon = TaskBarIcon()
            self.tbicon.SetIcon(icons.get_cpa_icon(), 'CPA/ImageGallery')
        else:
            self.SetIcon(icons.get_cpa_icon())
        self.SetName('ImageGallery')

        db.register_gui_parent(self)

        global dm
        dm = DataModel()

        if not p.is_initialized():
            logging.critical('ImageGallery requires a properties file. Exiting.')
            raise Exception('ImageGallery requires a properties file. Exiting.')

        self.pmb = None
        self.worker = None
        self.trainingSet = None
        self.classBins = []
        self.binsCreated = 0
        self.chMap = p.image_channel_colors[:]
        self.toggleChMap = p.image_channel_colors[
                           :]  # used to store previous color mappings when toggling colors on/off with ctrl+1,2,3...
        self.brightness = 1.0
        self.scale = 1.0 
        
        self.contrast = 'Linear'
        self.defaultTSFileName = None
        self.defaultModelFileName = None
        self.lastScoringFilter = None

        self.menuBar = wx.MenuBar()
        self.SetMenuBar(self.menuBar)
        self.CreateMenus()

        self.CreateStatusBar()

        #### Create GUI elements
        # Top level - three split windows
        self.splitter = wx.SplitterWindow(self, style=wx.NO_BORDER | wx.SP_3DSASH)
        self.bins_splitter = wx.SplitterWindow(self.splitter, style=wx.NO_BORDER | wx.SP_3DSASH)

        # fetch & rules
        self.fetch_panel = wx.Panel(self.splitter)

        # sorting bins
        self.gallery_panel = wx.Panel(self.bins_splitter)
        o_label = p.object_name[0] if p.classification_type == 'image' else '' + ' image gallery'
        self.gallery_box = wx.StaticBox(self.gallery_panel, label=o_label)
        self.gallery_sizer = wx.StaticBoxSizer(self.gallery_box, wx.VERTICAL)
        self.galleryBin = sortbin.SortBin(parent=self.gallery_panel,
                                               classifier=self,
                                               label='image gallery',
                                               parentSizer=self.gallery_sizer)
        self.gallery_sizer.Add(self.galleryBin, proportion=1, flag=wx.EXPAND)
        self.gallery_panel.SetSizer(self.gallery_sizer)
        self.objects_bin_panel = wx.Panel(self.bins_splitter)

        # fetch objects interface
        self.startId = wx.TextCtrl(self.fetch_panel, id=-1, value='1', size=(60, -1), style=wx.TE_PROCESS_ENTER)
        self.endId = wx.TextCtrl(self.fetch_panel, id=-1, value='100', size=(60, -1), style=wx.TE_PROCESS_ENTER)
        self.fetchChoice = wx.Choice(self.fetch_panel, id=-1, choices=['range','all','individual'])
        self.fetchChoice.SetSelection(0)
        self.filterChoice = wx.Choice(self.fetch_panel, id=-1,
                                      choices=['experiment'] + p._filters_ordered + p._groups_ordered + [
                                          CREATE_NEW_FILTER])
        self.fetchFromGroupSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.fetchBtn = wx.Button(self.fetch_panel, -1, 'Fetch!')

        #### Create Sizers
        self.fetchSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.classified_bins_sizer = wx.BoxSizer(wx.HORIZONTAL)

        #### Add elements to sizers and splitters
        # fetch panel
        self.fetchSizer.AddStretchSpacer()
        self.fetchSizer.Add(wx.StaticText(self.fetch_panel, -1, 'Fetch '), flag=wx.ALIGN_CENTER_VERTICAL)
        self.fetchSizer.Add(5, 20, 0)
        self.fetchSizer.Add(self.fetchChoice, flag=wx.ALIGN_CENTER_VERTICAL)
        self.fetchSizer.Add(5, 20, 0)
        self.fetchTxt = wx.StaticText(self.fetch_panel, -1, label='of image IDs:')
        self.fetchSizer.Add(self.fetchTxt, flag=wx.ALIGN_CENTER_VERTICAL)
        self.fetchSizer.Add(5, 20, 0)
        self.fetchSizer.Add(self.startId, flag=wx.ALIGN_CENTER_VERTICAL)
        self.fetchSizer.Add(5, 20, 0)
        self.fetchTxt2 = wx.StaticText(self.fetch_panel, -1, label='to')
        self.fetchSizer.Add(self.fetchTxt2, flag=wx.ALIGN_CENTER_VERTICAL)
        self.fetchSizer.Add(5, 20, 0)
        self.fetchSizer.Add(self.endId, flag=wx.ALIGN_CENTER_VERTICAL)
        self.fetchSizer.Add(5, 20, 0)
        #self.fetchSizer.Add(self.obClassChoice, flag=wx.ALIGN_CENTER_VERTICAL)
        #self.fetchSizer.Add(5, 20, 0)
        self.fetchTxt3 = wx.StaticText(self.fetch_panel, -1, label='images')
        self.fetchSizer.Add(self.fetchTxt3, flag=wx.ALIGN_CENTER_VERTICAL)
        self.fetchSizer.Add(5, 20, 0)
        self.fetchSizer.Add(wx.StaticText(self.fetch_panel, -1, 'from'), flag=wx.ALIGN_CENTER_VERTICAL)
        self.fetchSizer.Add(5, 20, 0)
        self.fetchSizer.Add(self.filterChoice, flag=wx.ALIGN_CENTER_VERTICAL)
        self.fetchSizer.Add(10, 20, 0)
        self.fetchSizer.Add(self.fetchFromGroupSizer, flag=wx.ALIGN_CENTER_VERTICAL)
        self.fetchSizer.Add(5, 20, 0)
        self.fetchSizer.Add(self.fetchBtn, flag=wx.ALIGN_CENTER_VERTICAL)
        self.fetchSizer.AddStretchSpacer()
        self.fetch_panel.SetSizerAndFit(self.fetchSizer)

        # classified bins panel
        self.objects_bin_panel.SetSizer(self.classified_bins_sizer)

        # splitter windows
        self.splitter.SplitHorizontally(self.fetch_panel, self.bins_splitter,
                                        self.fetch_panel.GetMinSize()[1])
        self.bins_splitter.SplitHorizontally(self.gallery_panel, self.objects_bin_panel)

        self.splitter.SetSashGravity(0.0)
        self.bins_splitter.SetSashGravity(0.5)

        self.splitter.SetMinimumPaneSize(max(50, self.fetch_panel.GetMinHeight()))
        self.bins_splitter.SetMinimumPaneSize(50)
        self.SetMinSize((self.fetch_panel.GetMinWidth(), 4 * 50 + self.fetch_panel.GetMinHeight()))

        # Set initial state
        self.filterChoice.SetSelection(0)

        # JEN - Start Add
        # self.openDimensReduxBtn.Disable()
        # JEN - End Add
        self.fetchSizer.Hide(self.fetchFromGroupSizer)

        #####################
        #### GUI Section ####
        #####################

        # add the default classes
        #for class in range(1, num_classes+1):
        self.AddSortClass('objects of selected image')
        #self.AddSortClass('negative')

        self.Layout()

        self.Center()
        self.MapChannels(p.image_channel_colors[:])
        self.BindMouseOverHelpText()

        #self.Bind(wx.EVT_BUTTON, self.OnInspect, self.inspectBtn)
        # JEN - Start Add
        # self.Bind(wx.EVT_BUTTON, self.OpenDimensRedux, self.openDimensReduxBtn)
        # JEN - End Add

        self.Bind(wx.EVT_BUTTON, self.OnFetch, self.fetchBtn)
        self.startId.Bind(wx.EVT_TEXT, self.ValidateIntegerField)
        self.startId.Bind(wx.EVT_TEXT_ENTER, self.OnFetch)

        self.Bind(wx.EVT_CLOSE, self.OnClose)
        self.Bind(wx.EVT_CHAR, self.OnKey)  # Doesn't work for windows
        tilecollection.EVT_TILE_UPDATED(self, self.OnTileUpdated)
        self.Bind(sortbin.EVT_QUANTITY_CHANGED, self.QuantityChanged)

        self.Bind(wx.EVT_CHOICE, self.OnSelectFetchChoice, self.fetchChoice)
        self.Bind(wx.EVT_CHOICE, self.OnSelectFilter, self.filterChoice)
예제 #5
0
    def __init__(self, model_):
        """
        """
        self.model = model_
        self._book = None
        self._book_id = None
        self._search_target = None

        super(KlipFrame, self).__init__(None,
                                        size=wx.Size(1200, 760),
                                        title='Klip',
                                        name='Klip')
        # ensure the parent's __init__ is called

        icon = icons.klip.GetIcon()
        self.SetIcon(icon)

        self.tb = TaskBarIcon(wx.adv.TBI_DOCK)
        self.tb.SetIcon(icon)

        sp = wx.SplitterWindow(self, style=wx.SP_BORDER | wx.SP_3DBORDER)
        sp.SetSplitMode(wx.SPLIT_VERTICAL)
        sp.SetMinimumPaneSize(50)
        self.detailPanel = KlipDetailWindow(self)
        self.SetMinSize(wx.Size(800, 600))

        # create a panel in the frame
        pnl_books = wx.Panel(sp)
        pnl_clips = wx.Panel(sp)
        pnl_clips.SetBackgroundColour(wx.Colour(255, 255, 255))

        sp.SplitVertically(pnl_books, pnl_clips,
                           int(round(self.GetSize().GetWidth() * 0.3)))

        sizer = wx.BoxSizer(wx.VERTICAL)

        self.search = wx.SearchCtrl(pnl_books,
                                    size=(200, -1),
                                    style=wx.TE_PROCESS_ENTER)
        self.search.ShowSearchButton(True)
        self.search.ShowCancelButton(True)

        self.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, self.OnSearch, self.search)
        self.Bind(wx.EVT_SEARCHCTRL_CANCEL_BTN, self.OnCancelSearch,
                  self.search)

        sizer.Add(self.search, 0, wx.EXPAND, 0)

        self.book_list = KlipListCtrl(pnl_books,
                                      wx.ID_ANY,
                                      style=wx.LC_REPORT | wx.LC_NO_HEADER
                                      | wx.LC_HRULES | wx.LC_SINGLE_SEL)

        font = self.book_list.GetFont()
        font.PointSize += 5
        # font = font.Bold()
        self.book_list.SetFont(font)
        self.book_list.SetForegroundColour(wx.Colour(0x43, 0x43, 0x43))
        self.book_list.ClearAll()
        self.book_list.SetBackgroundColour(wx.Colour(0xf6, 0xf6, 0xf6))

        self.bl_width = self.book_list.GetSize().GetWidth() * 0.5

        self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnBookSelected,
                  self.book_list)

        self._total_books = wx.StaticText(pnl_books,
                                          label="BOOKS (%d)" % 0,
                                          pos=(25, 25))

        sizer.Add(self._total_books, 0, wx.LEFT, 0)

        sizer.Add(self.book_list, 1, wx.EXPAND | wx.ALL, 0)

        pnl_books.SetSizer(sizer)

        # init right panel, show clippings.
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.book_title = wx.StaticText(pnl_clips, label='')

        font = self.book_title.GetFont()
        font.PointSize += 10
        font.Bold()
        self.book_title.SetFont(font)
        self.book_title.SetForegroundColour(wx.Colour(0x25, 0x91, 0xff))
        sizer.Add(self.book_title, 0, wx.EXPAND, 10)

        self.book_info = wx.StaticText(pnl_clips, label='')

        font = self.book_info.GetFont()
        font.PointSize += 5
        font.Bold()
        self.book_info.SetFont(font)
        # self.book_info.SetForegroundColour(wx.Colour(0x25, 0x91, 0xff))

        sizer.Add(self.book_info, 0, wx.EXPAND, 10)

        self.clip_list = KlipListCtrl(pnl_clips,
                                      wx.ID_ANY,
                                      style=wx.LC_REPORT | wx.LC_NO_HEADER
                                      | wx.LC_HRULES | wx.LC_SINGLE_SEL)

        self.clip_list.InsertColumn(0, "Clip")

        # books = self.fillBooks()

        sizer.Add(self.clip_list, 1, wx.EXPAND | wx.ALL, 0)

        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.showClipDetail,
                  self.clip_list)
        self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnClipSelected,
                  self.clip_list)

        pnl_clips.SetSizer(sizer)

        font = self.clip_list.GetFont()
        font.PointSize += 3
        self.clip_list.SetFont(font)

        width = self.clip_list.GetSize().GetWidth() * 0.5
        PDEBUG('Update Column Width: %d' % width)
        self.clip_list.SetColumnWidth(0, width)

        self.clip_list.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK,
                            self.OnRightClickClips)

        self.refreshContents()

        # create a menu bar
        self.makeMenuBar()