Esempio n. 1
0
    def __init__(self, parent, size=(21, 21), value=wx.BLACK):
        w, h = size[0] - 5, size[1] - 5
        GenBitmapButton.__init__(self, parent, wx.ID_ANY, wx.Bitmap(w, h),
                                 size=size)
        self.SetBezelWidth(1)

        self.parent = parent
        self.SetValue(value)

        self.parent.Bind(wx.EVT_BUTTON, self.OnClick, self)
Esempio n. 2
0
 def __init__(self, parent, ID=-1, bitmap=wx.NullBitmap,
              pos = wx.DefaultPosition, size = wx.DefaultSize,
              style = 0, validator = wx.DefaultValidator,
              name = "genbutton"):
     self.bitmap = bitmap
     GenBitmapButton.__init__(self, parent, ID, bitmap, pos, size, style, validator, name)
     self.SetBezelWidth(0)
     self.useFocusInd = False
     self.SetBestSize(None)
     self.Bind(wx.EVT_ENTER_WINDOW, self.ButtonOnMouseEnter)
     self.Bind(wx.EVT_LEAVE_WINDOW, self.ButtonOnMouseLeave)
Esempio n. 3
0
 def __init__(self, parent, ID=-1, bitmap=wx.NullBitmap,
              pos = wx.DefaultPosition, size = wx.DefaultSize,
              style = 0, validator = wx.DefaultValidator,
              name = "genbutton"):
     self.bitmap = bitmap
     GenBitmapButton.__init__(self, parent, ID, bitmap, pos, size, style, validator, name)
     self.SetBezelWidth(0)
     self.useFocusInd = False
     self.SetBestSize(None)
     self.Bind(wx.EVT_ENTER_WINDOW, self.ButtonOnMouseEnter)
     self.Bind(wx.EVT_LEAVE_WINDOW, self.ButtonOnMouseLeave)
Esempio n. 4
0
    def __init__(self, parent, size=(21, 21), value=wx.BLACK):
        w, h = size[0] - 5, size[1] - 5
        GenBitmapButton.__init__(self,
                                 parent,
                                 wx.ID_ANY,
                                 wx.Bitmap(w, h),
                                 size=size)
        self.SetBezelWidth(1)

        self.parent = parent
        self.SetValue(value)

        self.parent.Bind(wx.EVT_BUTTON, self.OnClick, self)
Esempio n. 5
0
def CreateGenButton(parent,
                    id,
                    bmp,
                    text=None,
                    tooltip=None,
                    colour=None,
                    font=None):
    """ Create a bitmap button. """

    if text is None:
        button = GenBitmapButton(parent, id, bmp, style=wx.SIMPLE_BORDER)
    else:
        button = GenBitmapTextButton(parent,
                                     id,
                                     bmp,
                                     text,
                                     style=wx.SIMPLE_BORDER)
        if font:
            button.SetFont(font)

    if tooltip is not None:
        button.SetToolTipString(tooltip)
    if colour is not None:
        button.SetBackgroundColour(colour)

    button.SetBezelWidth(0)
    button.SetUseFocusIndicator(False)

    return button
Esempio n. 6
0
    def _initialize_tool(self, param):
        """ Initialize the tool palette button. """

        wxid, label, bmp, kind, tooltip, longtip = param

        panel = self.control.FindWindowById(wxid)

        sizer = wx.BoxSizer(wx.VERTICAL)
        panel.SetSizer(sizer)
        panel.SetAutoLayout(True)
        panel.SetWindowStyleFlag(wx.CLIP_CHILDREN)

        from wx.lib.buttons import GenBitmapToggleButton, GenBitmapButton

        if kind == "radio":
            button = GenBitmapToggleButton(panel,
                                           -1,
                                           None,
                                           size=self.button_size)

        else:
            button = GenBitmapButton(panel, -1, None, size=self.button_size)

        self.button_tool_map[button.GetId()] = wxid
        self.tool_id_to_button_map[wxid] = button
        panel.Bind(wx.EVT_BUTTON, self._on_button, button)
        button.SetBitmapLabel(bmp)
        button.SetToolTip(label)
        sizer.Add(button, 0, wx.EXPAND)
Esempio n. 7
0
 def InitColours(self):
     """ Needed for correct background coloration """
     GenBitmapButton.InitColours(self)
     if self.background_parent:
         self.faceDnClr = self.background_parent.GetBackgroundColour()
     else:
         self.faceDnClr = self.GetParent().GetBackgroundColour()
 def __init__(self, imagepanel, sizer):
         bitmap = getBitmap('color.png')
         tooltip = 'Show Color'
         cursor = None
         imagepanel.colormap = None
         self.grayscalebitmap = getBitmap('grayscale.png')
         self.colorbitmap = bitmap
         button = GenBitmapButton(imagepanel, -1, bitmap, size=(24, 24))
         ImageTool.__init__(self, imagepanel, sizer, bitmap, tooltip, cursor, False,
                                                                                         button=button)
Esempio n. 9
0
    def AddSimpleTool(self,
                      wid,
                      bitmap,
                      shortHelpString='',
                      longHelpString='',
                      isToggle=0):
        """
		A method for adding a tool to the toolbar
		"""
        if not isToggle:
            #btn = wx.BitmapButton(self,id,bitmap,size=self.toolSize)
            btn = GenBitmapButton(self,
                                  wid,
                                  bitmap,
                                  style=wx.BORDER_NONE,
                                  size=self.toolSize)
        else:
            btn = GenBitmapToggleButton(self,
                                        wid,
                                        bitmap,
                                        size=(-1, self.toolSize[1]))

        btn.Bind(wx.EVT_BUTTON, self.onToolButton)
        btn.SetToolTipString(longHelpString)
        #self.sizer.Add(btn,(self.y,self.x))
        self.ctrls.append(btn)
        self.idToTool[wid] = btn
        self.sizes.append(btn.GetSize()[0])
        self.x += 1
Esempio n. 10
0
    def SetForegroundColour(self, colour):
        """Override. Apply fg colour to the image.

        :param colour: (wx.Colour)

        """
        try:
            bmp = self.GetBitmapLabel()
            img = bmp.ConvertToImage()
            current = self.GetForegroundColour()
            ColorizeImage(img, current, colour)
            self.SetBitmapLabel(wx.Bitmap(img))
        except:
            logging.debug('SetForegroundColour not applied to image'
                          'for button {:s}'.format(self.GetName()))

        GenBitmapButton.SetForegroundColour(self, colour)
Esempio n. 11
0
class Calender(wx.Frame):

    def __init__(self, parent, title):
        no_caption = wx.MINIMIZE_BOX | wx.MAXIMIZE_BOX | wx.SYSTEM_MENU | wx.CLOSE_BOX | wx.CLIP_CHILDREN
        # super().__init__(parent, title=title, style=no_caption)
        super().__init__(parent, title=title)

        self.InitUI()
        self.SetSize(1080,620)
        self.SetBackgroundColour(c_dunkel)
        self.Centre()

    # ========================= Anordnung der Elemente der GUI ================================
    def InitUI(self):

        # creating main-structure
        self.mainBox = wx.BoxSizer(wx.VERTICAL)         # MAINWINDOW = Everything
        self.navBox = wx.BoxSizer(wx.VERTICAL)          # Bar on the Right for Navigation
        self.windowBox = wx.BoxSizer(wx.HORIZONTAL)     # Window Left from the Navbar
        self.titleBox = wx.BoxSizer(wx.HORIZONTAL)      # Bar on Top with Date
        self.contentWindow = wx.BoxSizer(wx.VERTICAL)   # Necessarry for switching different panels in WindowBox

        # Initializing different MainPages (Home,Traum,Jahresplan...)
        self.init_contentPages()
        self.organize_contentPages()

        self.border = 5

        # ========================= NavBar ================================
        #Create NavButtons
        self.home_btn = GenBitmapButton(self, -1,wx.Bitmap(wx.Image("icon/home.png", wx.BITMAP_TYPE_PNG)))
        self.dream_btn = GenBitmapButton(self, -1,wx.Bitmap(wx.Image("icon/traum.png", wx.BITMAP_TYPE_PNG)))
        self.fiveyearplay_btn = GenBitmapButton(self, -1,wx.Bitmap(wx.Image("icon/5jahresplan.png", wx.BITMAP_TYPE_PNG)))
        self.yearplan_btn = GenBitmapButton(self, -1,wx.Bitmap(wx.Image("icon/jahresplan.png", wx.BITMAP_TYPE_PNG)))
        self.monthplan_btn = GenBitmapButton(self, -1,wx.Bitmap(wx.Image("icon/monatsplan.png", wx.BITMAP_TYPE_PNG)))
        self.dayplan_btn = GenBitmapButton(self, -1,wx.Bitmap(wx.Image("icon/tagesplan.png", wx.BITMAP_TYPE_PNG)))
        self.habittrrack_btn = GenBitmapButton(self, -1,wx.Bitmap(wx.Image("icon/habittrack.png", wx.BITMAP_TYPE_PNG)))

        #Storing NavButtonData
        navButtonDict = {
            self.home_btn: "home",
            self.dream_btn: "traum",
            self.fiveyearplay_btn: "5jahresplan",
            self.yearplan_btn: "jahresplan",
            self.monthplan_btn: "monatsplan",
            self.dayplan_btn: "tagesplan",
            self.habittrrack_btn: "habittrack",
        }

        #Design NavButtons
        for button in navButtonDict:
            self.set_NavigationButtons(button, str(navButtonDict[button]))
            self.design_NavigationButtons(button)
            self.navBox.Add(button, 1 , wx.ALL , self.border)
        #Bind NavButtons
        self.bind_NavigationButtons()

        self.navBox.AddStretchSpacer(3)

        # ========================= TitleBar ================================
        look = wx.Panel(self)

        self.close_btn = GenBitmapButton(self, -1,wx.Bitmap(wx.Image("icon/close.png", wx.BITMAP_TYPE_PNG)),(-1,-1),(65,-1))
        self.set_NavigationButtons(self.close_btn, str("close"))
        self.design_NavigationButtons(self.close_btn)
        self.close_btn.Bind(wx.EVT_BUTTON, self.OnCloseClicked)

        font_dayHeader = wx.Font(28, fontfamily, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, schriftart)
        if int(aktuellerTag) < 10:
            titleBox_day = "  " + "0" + aktuellerTag + " " + self.getWeekday()
        else:
            titleBox_day = aktuellerTag + " " + self.getWeekday()
        dayHeader = wx.StaticText(self, 1, titleBox_day)
        dayHeader.SetFont(font_dayHeader)
        dayHeader.SetForegroundColour(wx.Colour(c_hell))

        font_monthHeader = wx.Font(12, wx.FONTFAMILY_SWISS, wx.NORMAL, wx.FONTWEIGHT_LIGHT, False, "Verdana")
        monthHeader = wx.StaticText(self, 1, self.getMonth())
        monthHeader.SetFont(font_monthHeader)
        monthHeader.SetForegroundColour(wx.Colour(c_hell))

        if int(aktuellerTag) > 9:
            self.titleBox.AddSpacer(70)
        else:
            self.titleBox.AddSpacer(50)
        self.titleBox.Add(dayHeader, wx.EXPAND | wx.ALL, wx.ALIGN_CENTER)
        self.titleBox.Add(monthHeader, wx.EXPAND | wx.ALL, wx.ALIGN_CENTER)
        self.titleBox.Add(self.close_btn, wx.ALL, wx.ALIGN_CENTER, 10)

        # ========================= MainWindow ================================

        self.windowBox.Add(self.navBox, -1, wx.EXPAND | wx.ALL)
        self.windowBox.Add(self.contentWindow, 10, wx.EXPAND |wx.ALL)
        self.mainBox.Add(self.titleBox, -1, wx.EXPAND | wx.ALL)
        self.mainBox.Add(self.windowBox, 10, wx.EXPAND | wx.ALL)

        self.SetSizer(self.mainBox)

    # ========================= Methoden ================================
    def set_NavigationButtons(self, button, name):
        # Function for dealing with Basic Button Setups (NavigationButtons)
        button.SetToolTip(name)
        button.SetBitmapSelected(wx.Bitmap(wx.Image("icon/"+name+"_selected.png", wx.BITMAP_TYPE_PNG)))
        button.SetBitmapFocus(wx.Bitmap(wx.Image("icon/"+name+"_focus.png", wx.BITMAP_TYPE_PNG)))

    def design_NavigationButtons(self, button):
        # Function for simplifying ButtonDesign
        button.SetBezelWidth(0)
        button.SetUseFocusIndicator(False)
        button.SetBackgroundColour(c_dunkel)

    def bind_NavigationButtons(self):
        self.home_btn.Bind(wx.EVT_BUTTON, self.OnHomeClicked)
        self.dream_btn.Bind(wx.EVT_BUTTON, self.OnDreamClicked)
        self.fiveyearplay_btn.Bind(wx.EVT_BUTTON, self.On5YearClicked)
        self.yearplan_btn.Bind(wx.EVT_BUTTON, self.OnYearClicked)
        self.monthplan_btn.Bind(wx.EVT_BUTTON, self.OnMonthClicked)
        self.dayplan_btn.Bind(wx.EVT_BUTTON, self.OnDayClicked)
        self.habittrrack_btn.Bind(wx.EVT_BUTTON, self.OnHabittrackClicked)

    def getWeekday(self):
        switcher = { 0: "MO", 1: "DI", 2: "MI", 3: "DO",  4: "FR", 5: "SA",  6: "SO"}
        return switcher.get(datetime.datetime.today().weekday(), "Ungültiger Tag")

    def getMonth(self):
        switcher = {
            1: "Januar",
            2: "Februar",
            3: "März",
            4: "April",
            5: "Mai",
            6: "Juni",
            7: "Juli",
            8: "August",
            9: "September",
            10: "Oktober",
            11: "November",
            12: "Dezember"
        }
        return switcher.get(int(aktuellerMonat), "Ungültiger Monat")

    def init_contentPages(self):
        #creating contentPages
        self.page_home = Home(self)
        self.page_traum = TraumSeite(self)
        self.page_fuenfJahresPlan = FuenfJahresPlanSeite(self)
        self.page_jahresplan = JahresSeite(self)
        self.page_monatsplan = MonatsSeite(self)
        self.page_tagesplan = TagesSeite(self)
        self.page_habittracker = HabitTracker(self)
        # Hiding UnseenPages at Programstart, Showing HomePage First
        self.panelSwitch(self.page_home)

    def organize_contentPages(self):
        pageList = [self.page_home, self.page_traum, self.page_fuenfJahresPlan,
                    self.page_jahresplan, self.page_monatsplan, self.page_tagesplan, self.page_habittracker]
        for page in pageList:
            self.contentWindow.Add(page,1, wx.EXPAND)

    def panelSwitch(self, page):
        pageList = [self.page_home, self.page_traum, self.page_fuenfJahresPlan, self.page_jahresplan, self.page_monatsplan, self.page_tagesplan, self.page_habittracker]
        pageList_shortend = pageList
        pageList_shortend.remove(page)
        page.Show()
        for pages in pageList_shortend:
            pages.Hide()
        self.Layout()

    # Event Handlers for Navigation
    def OnHomeClicked(self, e):
        self.panelSwitch(self.page_home)
        print("Home gedrückt")

    def OnDreamClicked(self, e):
        self.panelSwitch(self.page_traum)
        print("Traum gedrückt")

    def On5YearClicked(self, e):
        self.panelSwitch(self.page_fuenfJahresPlan)
        print("5-Jahresplan gedrückt")

    def OnYearClicked(self, e):
        self.panelSwitch(self.page_jahresplan)
        print("Jahresplan gedrückt")

    def OnMonthClicked(self, e):
        self.panelSwitch(self.page_monatsplan)
        self.Layout()
        print("Monatsplan gedrückt")

    def OnDayClicked(self, e):
        self.panelSwitch(self.page_tagesplan)
        print("Tagesplan gedrückt")

    def OnHabittrackClicked(self, e):
        self.panelSwitch(self.page_habittracker)
        print("Habittrack gedrückt")

    def OnCloseClicked(self, e):
        self.Destroy()
Esempio n. 12
0
    def __init__(self, *args, **kwargs):
        """ If the background_parent keyword argument is provided, it will be
        used to determine the background colour of the button. Otherwise, the
        direct parent will be used.

        :param parent: (wx.Window) parent window
        :param id: (int) button id (optional)
        :param bitmap: (wx.Bitmap) default button face. Use `SetBitmaps` to set
                the other faces (e.g. hover, active)
        :param pos: (int, int)) button position
        :param size: (int, int) button size
        :param background_parent: (wx.Window) any parent higher up in the
                hierarchy from which to pick the background colour. (optional)
        :param label_delta: (int) the number of pixels to move button text down
                and to the right when it is pressed, to create an indentation
                effect. (This is used by subclasses that allow text to be
                displayed)

        """

        if kwargs.has_key('style'):
            kwargs['style'] |= wx.NO_BORDER
        else:
            kwargs['style'] = wx.NO_BORDER

        self.background_parent = kwargs.pop('background_parent', None)
        self.labelDelta = kwargs.pop('label_delta', 0)

        # Fit the bmp if needed
        # Resizing should always be minimal, so distortion is minimum

        # If the bmp arg is provided (which is the 3rd one: parent, id, bmp)

        bmp = args[2] if len(args) >= 3 else kwargs.get('bitmap', None)
        size = args[4] if len(args) >= 5 else kwargs.get('size', None)

        if bmp:
            if size and size != (-1, -1):
                args = list(args)
                # Resize and replace original bmp
                if len(args) >= 3:
                    args[2] = resize_bmp(size, bmp)
                else:
                    kwargs['bitmap'] = resize_bmp(size, bmp)
            else:
                # Set the size of the button to match the bmp
                if len(args) >= 5:
                    args[4] = bmp.GetSize()
                else:
                    kwargs['size'] = bmp.GetSize()

        GenBitmapButton.__init__(self, *args, **kwargs)

        if self.background_parent:
            self.SetBackgroundColour(
                self.background_parent.GetBackgroundColour()
            )
        else:
            self.SetBackgroundColour(self.GetParent().GetBackgroundColour())

        self.bmpHover = None
        self.hovering = False

        self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter)
        self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave)
Esempio n. 13
0
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(960, 700))
        # menu okna głównego ------------------------------------------
        self.CreateStatusBar()
        menuBar = wx.MenuBar()
        menu = wx.Menu()
        pomoc = wx.Menu()
        menu.Append(100, "&Kalkulator foremek")
        menu.Append(101, "&Przelicznik kulinarny")
        menu.Append(102, "&Ulubione")
        menu.Append(99, "&Zamknij")
        pomoc.Append(103, "&Aktualizacja")
        pomoc.Append(104, "&O programie")
        menuBar.Append(menu, "&Menu")
        menuBar.Append(pomoc, "&Pomoc")
        self.SetMenuBar(menuBar)
        self.Bind(wx.EVT_MENU, self.wyjscie, id=99)
        self.Bind(wx.EVT_MENU, self.foremki, id=100)
        self.Bind(wx.EVT_MENU, self.jednostki, id=101)
        self.Bind(wx.EVT_MENU, self.ulubione, id=102)
        self.Bind(wx.EVT_MENU, self.aktualizacja, id=103)
        self.Bind(wx.EVT_MENU, self.about, id=104)
        # -------------------------------------------------------------
        # okno główne - wyszukiwarka + jej wygląd -----------------------
        panel = wx.Panel(self)
        panel.SetBackgroundColour('white')
        self.entrytext = wx.TextCtrl(
            panel, value="Wpisz frazę, którą chcesz wyszukać")
        self.entrytext.SetForegroundColour((0, 0, 0))
        button = wx.Button(panel, label="Szukaj")
        radio1 = wx.RadioButton(panel,
                                -1,
                                " po nazwach potraw ",
                                style=wx.RB_GROUP)
        radio2 = wx.RadioButton(panel, -1, " po składnikach ")
        button1 = wx.Button(panel, label="+ Dodaj przepis")

        button.Bind(wx.EVT_BUTTON, self.Search)
        radio1.Bind(wx.EVT_RADIOBUTTON, self.radiobutton)
        radio2.Bind(wx.EVT_RADIOBUTTON, self.radiobutton)
        button1.Bind(wx.EVT_BUTTON, self.Add)

        radio1.SetForegroundColour('black')
        radio2.SetForegroundColour('black')
        button.SetBackgroundColour((50, 50, 50))
        button.SetForegroundColour('white')
        button1.SetBackgroundColour((50, 50, 50))
        button1.SetForegroundColour('white')

        self.sizer = wx.GridBagSizer(5, 5)
        self.sizer.Add(self.entrytext, (7, 10), (1, 12), wx.EXPAND)
        self.sizer.Add(button, (7, 22))
        self.sizer.Add(button1, (0, 0))
        self.sizer.Add(radio1, (8, 11))
        self.sizer.Add(radio2, (8, 15))

        # -------------------------------------------------------------

        # okno główne - wygląd ----------------------------------------
        logofile = pwd + "logo.png"
        logopng = scale(logofile, 200, 150)
        wx.StaticBitmap(panel, -1, logopng, (360, 15),
                        (logopng.GetWidth(), logopng.GetHeight()))
        # -------------------------------------------------------------

        # okno główne - inspiracje ----------------------------------------
        names, imagefiles = self.inspiracje()
        imgbuttons = [0] * 5
        for i in range(4):
            imagefile = imagefiles[i]
            imagefile = imagefile + ".jpg"
            img = scale(imagefile, 175, 250)
            h = img.GetHeight()
            imgbutton = GenBitmapButton(panel, -1, img,
                                        (50 + 225 * i, 475 - h / 2))
            imgbuttons[i] = imgbutton
            text = wx.StaticText(panel, -1, names[i],
                                 (55 + 225 * i, 495 + h / 2 + 10))
            text.SetForegroundColour((0, 0, 0))
            text.Wrap(175)

        imgbuttons[0].Bind(wx.EVT_BUTTON,
                           lambda event: imgEvent(names[0], self))
        imgbuttons[1].Bind(wx.EVT_BUTTON,
                           lambda event: imgEvent(names[1], self))
        imgbuttons[2].Bind(wx.EVT_BUTTON,
                           lambda event: imgEvent(names[2], self))
        imgbuttons[3].Bind(wx.EVT_BUTTON,
                           lambda event: imgEvent(names[3], self))

        text = wx.StaticText(panel,
                             -1,
                             'Przepisy na dziś', (375, 310),
                             style=wx.ALIGN_CENTRE)
        text.SetForegroundColour((0, 0, 0))
        font = wx.Font(18, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL)
        text.SetFont(font)
        # -------------------------------------------------------------
        panel.SetSizer(self.sizer)
Esempio n. 14
0
class BaseImplantEditorView(wx.Panel):
    def addMarketViewImage(self, iconFile):
        if iconFile is None:
            return -1
        bitmap = BitmapLoader.getBitmap(iconFile, "icons")
        if bitmap is None:
            return -1
        else:
            return self.availableImplantsImageList.Add(bitmap)

    def __init__(self, parent):
        wx.Panel.__init__(self,
                          parent,
                          id=wx.ID_ANY,
                          pos=wx.DefaultPosition,
                          size=wx.DefaultSize,
                          style=wx.TAB_TRAVERSAL)
        self.SetBackgroundColour(
            wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW))

        pmainSizer = wx.BoxSizer(wx.HORIZONTAL)

        availableSizer = wx.BoxSizer(wx.VERTICAL)

        self.searchBox = SearchBox(self)
        self.itemView = ItemView(self)

        self.itemView.Hide()

        availableSizer.Add(self.searchBox, 0, wx.EXPAND)
        availableSizer.Add(self.itemView, 1, wx.EXPAND)
        '''
        self.availableImplantsSearch = wx.SearchCtrl(self, wx.ID_ANY, style=wx.TE_PROCESS_ENTER)
        self.availableImplantsSearch.ShowCancelButton(True)

        availableSizer.Add(self.availableImplantsSearch, 0, wx.BOTTOM | wx.EXPAND, 2)
        '''

        self.availableImplantsTree = wx.TreeCtrl(self,
                                                 wx.ID_ANY,
                                                 style=wx.TR_DEFAULT_STYLE
                                                 | wx.TR_HIDE_ROOT)
        root = self.availableRoot = self.availableImplantsTree.AddRoot(
            "Available")
        self.availableImplantsImageList = wx.ImageList(16, 16)
        self.availableImplantsTree.SetImageList(
            self.availableImplantsImageList)

        availableSizer.Add(self.availableImplantsTree, 1, wx.EXPAND)

        pmainSizer.Add(availableSizer, 1, wx.ALL | wx.EXPAND, 5)

        buttonSizer = wx.BoxSizer(wx.VERTICAL)
        buttonSizer.AddStretchSpacer()

        self.btnAdd = GenBitmapButton(self,
                                      wx.ID_ADD,
                                      BitmapLoader.getBitmap(
                                          "fit_add_small", "gui"),
                                      style=wx.BORDER_NONE)
        buttonSizer.Add(self.btnAdd, 0)

        self.btnRemove = GenBitmapButton(self,
                                         wx.ID_REMOVE,
                                         BitmapLoader.getBitmap(
                                             "fit_delete_small", "gui"),
                                         style=wx.BORDER_NONE)
        buttonSizer.Add(self.btnRemove, 0)

        buttonSizer.AddStretchSpacer()
        pmainSizer.Add(buttonSizer, 0, wx.EXPAND, 0)

        characterImplantSizer = wx.BoxSizer(wx.VERTICAL)
        self.pluggedImplantsTree = AvailableImplantsView(self)
        characterImplantSizer.Add(self.pluggedImplantsTree, 1,
                                  wx.ALL | wx.EXPAND, 5)
        pmainSizer.Add(characterImplantSizer, 1, wx.EXPAND, 5)

        self.SetSizer(pmainSizer)

        # Populate the market tree

        sMkt = Market.getInstance()
        for mktGrp in sMkt.getImplantTree():
            iconId = self.addMarketViewImage(sMkt.getIconByMarketGroup(mktGrp))
            childId = self.availableImplantsTree.AppendItem(root,
                                                            mktGrp.name,
                                                            iconId,
                                                            data=mktGrp.ID)
            if sMkt.marketGroupHasTypesCheck(mktGrp) is False:
                self.availableImplantsTree.AppendItem(childId, "dummy")

        self.availableImplantsTree.SortChildren(self.availableRoot)

        # Bind the event to replace dummies by real data
        self.availableImplantsTree.Bind(wx.EVT_TREE_ITEM_EXPANDING,
                                        self.expandLookup)
        self.availableImplantsTree.Bind(wx.EVT_TREE_ITEM_ACTIVATED,
                                        self.itemSelected)

        self.itemView.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.itemSelected)

        # Bind add & remove buttons
        self.btnAdd.Bind(wx.EVT_BUTTON, self.itemSelected)
        self.btnRemove.Bind(wx.EVT_BUTTON, self.removeItem)

        # We update with an empty list first to set the initial size for Layout(), then update later with actual
        # implants for character. This helps with sizing issues.
        self.pluggedImplantsTree.update([])
        self.bindContext()
        self.Layout()

        self.update()

    def bindContext(self):
        # Binds self.contextChanged to whatever changes the context
        raise NotImplementedError()

    def getImplantsFromContext(self):
        """ Gets list of implants from current context """
        raise NotImplementedError()

    def addImplantToContext(self, item):
        """ Adds implant to the current context"""
        raise NotImplementedError()

    def removeImplantFromContext(self, implant):
        """ Removes implant from the current context"""
        raise NotImplementedError()

    def update(self):
        """Updates implant list based off the current context"""
        self.implants = self.getImplantsFromContext()
        self.implants.sort(
            key=lambda i: int(i.getModifiedItemAttr("implantness")))
        self.pluggedImplantsTree.update(self.implants)

    def contextChanged(self, event):
        self.update()
        event.Skip()

    def expandLookup(self, event):
        tree = self.availableImplantsTree
        sMkt = Market.getInstance()
        parent = event.Item
        child, _ = tree.GetFirstChild(parent)
        text = tree.GetItemText(child)

        if text == "dummy" or text == "itemdummy":
            tree.Delete(child)

        # if the dummy item is a market group, replace with actual market groups
        if text == "dummy":
            # Add 'real stoof!' instead
            currentMktGrp = sMkt.getMarketGroup(tree.GetItemData(parent),
                                                eager="children")
            for childMktGrp in sMkt.getMarketGroupChildren(currentMktGrp):
                iconId = self.addMarketViewImage(
                    sMkt.getIconByMarketGroup(childMktGrp))
                childId = tree.AppendItem(parent,
                                          childMktGrp.name,
                                          iconId,
                                          data=childMktGrp.ID)
                if sMkt.marketGroupHasTypesCheck(childMktGrp) is False:
                    tree.AppendItem(childId, "dummy")
                else:
                    tree.AppendItem(childId, "itemdummy")

        # replace dummy with actual items
        if text == "itemdummy":
            currentMktGrp = sMkt.getMarketGroup(tree.GetItemData(parent))
            items = sMkt.getItemsByMarketGroup(currentMktGrp)
            for item in items:
                iconId = self.addMarketViewImage(item.iconID)
                tree.AppendItem(parent, item.name, iconId, data=item)

        tree.SortChildren(parent)

    def itemSelected(self, event):
        if event.EventObject is self.btnAdd:
            # janky fix that sets EventObject so that we don't have similar code elsewhere.
            if self.itemView.IsShown():
                event.EventObject = self.itemView
            else:
                event.EventObject = self.availableImplantsTree

        if event.EventObject is self.itemView:
            curr = event.EventObject.GetFirstSelected()

            while curr != -1:
                item = self.itemView.items[curr]
                self.addImplantToContext(item)

                curr = event.EventObject.GetNextSelected(curr)
        else:
            root = self.availableImplantsTree.GetSelection()

            if not root.IsOk():
                return

            nchilds = self.availableImplantsTree.GetChildrenCount(root)
            if nchilds == 0:
                item = self.availableImplantsTree.GetItemData(root)
                self.addImplantToContext(item)
            else:
                event.Skip()
                return

        self.update()

    def removeItem(self, event):
        pos = self.pluggedImplantsTree.GetFirstSelected()
        if pos != -1:
            self.removeImplantFromContext(self.implants[pos])
            self.update()
Esempio n. 15
0
 def __init__(self, parent, id, bitmap, pos, size, style):
     GenBitmapButton.__init__(self, parent, id, bitmap, pos, size, style)
     self.bgcolor = wx.Brush(wx.WHITE)
Esempio n. 16
0
    def __init__(self, parent):
        wx.Panel.__init__(self,
                          parent,
                          id=wx.ID_ANY,
                          pos=wx.DefaultPosition,
                          size=wx.Size(500, 300),
                          style=wx.TAB_TRAVERSAL)

        pmainSizer = wx.BoxSizer(wx.HORIZONTAL)

        availableSizer = wx.BoxSizer(wx.VERTICAL)
        pmainSizer.Add(availableSizer, 1, wx.ALL | wx.EXPAND, 5)

        self.availableImplantsSearch = wx.SearchCtrl(self,
                                                     wx.ID_ANY,
                                                     style=wx.TE_PROCESS_ENTER)
        self.availableImplantsSearch.ShowCancelButton(True)
        availableSizer.Add(self.availableImplantsSearch, 0,
                           wx.BOTTOM | wx.EXPAND, 2)

        self.availableImplantsTree = wx.TreeCtrl(self,
                                                 wx.ID_ANY,
                                                 style=wx.TR_DEFAULT_STYLE
                                                 | wx.TR_HIDE_ROOT)
        root = self.availableRoot = self.availableImplantsTree.AddRoot(
            "Available")
        self.availableImplantsImageList = wx.ImageList(16, 16)
        self.availableImplantsTree.SetImageList(
            self.availableImplantsImageList)

        availableSizer.Add(self.availableImplantsTree, 1, wx.EXPAND)

        buttonSizer = wx.BoxSizer(wx.VERTICAL)
        pmainSizer.Add(buttonSizer, 0, wx.TOP, 5)

        self.btnAdd = GenBitmapButton(self,
                                      wx.ID_ADD,
                                      bitmapLoader.getBitmap(
                                          "fit_add_small", "icons"),
                                      style=wx.BORDER_NONE)
        buttonSizer.Add(self.btnAdd, 0)
        self.btnRemove = GenBitmapButton(self,
                                         wx.ID_REMOVE,
                                         bitmapLoader.getBitmap(
                                             "fit_delete_small", "icons"),
                                         style=wx.BORDER_NONE)
        buttonSizer.Add(self.btnRemove, 0)

        self.pluggedImplantsTree = AvailableImplantsView(
            self, style=wx.LC_SINGLE_SEL)

        pmainSizer.Add(self.pluggedImplantsTree, 1, wx.ALL | wx.EXPAND, 5)

        self.SetSizer(pmainSizer)

        # Populate the market tree
        sMkt = service.Market.getInstance()
        for mktGrp in sMkt.getImplantTree():
            iconId = self.addMarketViewImage(sMkt.getIconByMarketGroup(mktGrp))
            childId = self.availableImplantsTree.AppendItem(
                root, mktGrp.name, iconId, data=wx.TreeItemData(mktGrp.ID))
            if sMkt.marketGroupHasTypesCheck(mktGrp) is False:
                self.availableImplantsTree.AppendItem(childId, "dummy")

        self.availableImplantsTree.SortChildren(self.availableRoot)

        #Bind the event to replace dummies by real data
        self.availableImplantsTree.Bind(wx.EVT_TREE_ITEM_EXPANDING,
                                        self.expandLookup)

        #Bind add & remove buttons
        self.btnAdd.Bind(wx.EVT_BUTTON, self.addImplant)
        self.btnRemove.Bind(wx.EVT_BUTTON, self.removeImplant)

        #Bind the change of a character*
        self.Parent.Parent.Bind(GE.CHAR_CHANGED, self.charChanged)
        self.Enable(False)
        self.Layout()
Esempio n. 17
0
class ImplantsTreeView(wx.Panel):
    def addMarketViewImage(self, iconFile):
        if iconFile is None:
            return -1
        bitmap = bitmapLoader.getBitmap(iconFile, "pack")
        if bitmap is None:
            return -1
        else:
            return self.availableImplantsImageList.Add(bitmap)

    def __init__(self, parent):
        wx.Panel.__init__(self,
                          parent,
                          id=wx.ID_ANY,
                          pos=wx.DefaultPosition,
                          size=wx.Size(500, 300),
                          style=wx.TAB_TRAVERSAL)

        pmainSizer = wx.BoxSizer(wx.HORIZONTAL)

        availableSizer = wx.BoxSizer(wx.VERTICAL)
        pmainSizer.Add(availableSizer, 1, wx.ALL | wx.EXPAND, 5)

        self.availableImplantsSearch = wx.SearchCtrl(self,
                                                     wx.ID_ANY,
                                                     style=wx.TE_PROCESS_ENTER)
        self.availableImplantsSearch.ShowCancelButton(True)
        availableSizer.Add(self.availableImplantsSearch, 0,
                           wx.BOTTOM | wx.EXPAND, 2)

        self.availableImplantsTree = wx.TreeCtrl(self,
                                                 wx.ID_ANY,
                                                 style=wx.TR_DEFAULT_STYLE
                                                 | wx.TR_HIDE_ROOT)
        root = self.availableRoot = self.availableImplantsTree.AddRoot(
            "Available")
        self.availableImplantsImageList = wx.ImageList(16, 16)
        self.availableImplantsTree.SetImageList(
            self.availableImplantsImageList)

        availableSizer.Add(self.availableImplantsTree, 1, wx.EXPAND)

        buttonSizer = wx.BoxSizer(wx.VERTICAL)
        pmainSizer.Add(buttonSizer, 0, wx.TOP, 5)

        self.btnAdd = GenBitmapButton(self,
                                      wx.ID_ADD,
                                      bitmapLoader.getBitmap(
                                          "fit_add_small", "icons"),
                                      style=wx.BORDER_NONE)
        buttonSizer.Add(self.btnAdd, 0)
        self.btnRemove = GenBitmapButton(self,
                                         wx.ID_REMOVE,
                                         bitmapLoader.getBitmap(
                                             "fit_delete_small", "icons"),
                                         style=wx.BORDER_NONE)
        buttonSizer.Add(self.btnRemove, 0)

        self.pluggedImplantsTree = AvailableImplantsView(
            self, style=wx.LC_SINGLE_SEL)

        pmainSizer.Add(self.pluggedImplantsTree, 1, wx.ALL | wx.EXPAND, 5)

        self.SetSizer(pmainSizer)

        # Populate the market tree
        sMkt = service.Market.getInstance()
        for mktGrp in sMkt.getImplantTree():
            iconId = self.addMarketViewImage(sMkt.getIconByMarketGroup(mktGrp))
            childId = self.availableImplantsTree.AppendItem(
                root, mktGrp.name, iconId, data=wx.TreeItemData(mktGrp.ID))
            if sMkt.marketGroupHasTypesCheck(mktGrp) is False:
                self.availableImplantsTree.AppendItem(childId, "dummy")

        self.availableImplantsTree.SortChildren(self.availableRoot)

        #Bind the event to replace dummies by real data
        self.availableImplantsTree.Bind(wx.EVT_TREE_ITEM_EXPANDING,
                                        self.expandLookup)

        #Bind add & remove buttons
        self.btnAdd.Bind(wx.EVT_BUTTON, self.addImplant)
        self.btnRemove.Bind(wx.EVT_BUTTON, self.removeImplant)

        #Bind the change of a character*
        self.Parent.Parent.Bind(GE.CHAR_CHANGED, self.charChanged)
        self.Enable(False)
        self.Layout()

    def update(self, implants):
        self.implants = implants[:]
        self.implants.sort(
            key=lambda i: int(i.getModifiedItemAttr("implantness")))
        self.pluggedImplantsTree.update(self.implants)

    def charChanged(self, event):
        cChar = service.Character.getInstance()
        charID = self.Parent.Parent.getActiveCharacter()
        name = cChar.getCharName(charID)
        if name == "All 0" or name == "All 5":
            self.Enable(False)
        else:
            self.Enable(True)

        self.update(cChar.getImplants(charID))
        event.Skip()

    def expandLookup(self, event):
        tree = self.availableImplantsTree
        root = event.Item
        child, cookie = tree.GetFirstChild(root)
        text = tree.GetItemText(child)
        if text == "dummy" or text == "itemdummy":
            cMarket = service.Market.getInstance()
            #A DUMMY! Keeeel!!! EBUL DUMMY MUST DIAF!
            tree.Delete(child)

        if text == "dummy":
            #Add 'real stoof!' instead
            for id, name, iconFile, more in cMarket.getChildren(
                    tree.GetPyData(root)):
                iconId = self.addMarketViewImage(iconFile)
                childId = tree.AppendItem(root,
                                          name,
                                          iconId,
                                          data=wx.TreeItemData(id))
                if more:
                    tree.AppendItem(childId, "dummy")
                else:
                    tree.AppendItem(childId, "itemdummy")

        if text == "itemdummy":
            cMarket = service.Market.getInstance()
            data, usedMetas = cMarket.getVariations(tree.GetPyData(root))
            for item in data:
                id = item.ID
                name = item.name
                iconFile = item.icon.iconFile
                iconId = self.addMarketViewImage(iconFile)
                tree.AppendItem(root, name, iconId, data=wx.TreeItemData(id))

        tree.SortChildren(root)

    def addImplant(self, event):
        root = self.availableImplantsTree.GetSelection()

        if not root.IsOk():
            return

        nchilds = self.availableImplantsTree.GetChildrenCount(root)
        cChar = service.Character.getInstance()
        charID = self.Parent.Parent.getActiveCharacter()
        if nchilds == 0:
            itemID = self.availableImplantsTree.GetPyData(root)
            cChar.addImplant(charID, itemID)
            self.update(cChar.getImplants(charID))

    def removeImplant(self, event):
        pos = self.pluggedImplantsTree.GetFirstSelected()
        if pos != -1:
            cChar = service.Character.getInstance()
            charID = self.Parent.Parent.getActiveCharacter()
            cChar.removeImplant(charID, self.implants[pos].slot)
            self.update(cChar.getImplants(charID))
Esempio n. 18
0
class Calender(wx.Frame):
    def __init__(self, parent, title):
        no_caption = wx.MINIMIZE_BOX | wx.MAXIMIZE_BOX | wx.SYSTEM_MENU | wx.CLOSE_BOX | wx.CLIP_CHILDREN
        # super().__init__(parent, title=title, style=no_caption)
        super().__init__(parent, title=title)

        self.InitUI()
        self.SetSize(1080, 620)
        self.SetBackgroundColour(c_dunkel)
        self.Centre()

    # ========================= Anordnung der Elemente der GUI ================================
    def InitUI(self):

        # Initializing different MainPages
        self.page_home = self.Home(self)
        self.page_traum = self.TraumSeite(self)
        self.page_fuenfJahresPlan = self.FuenfJahresPlanSeite(self)
        self.page_jahresplan = self.JahresSeite(self)
        self.page_monatsplan = self.MonatsSeite(self)
        self.page_tagesplan = self.TagesSeite(self)
        self.page_habittracker = self.HabitTracker(self)

        self.border = 5

        # creating main-structure
        self.mainBox = wx.BoxSizer(wx.VERTICAL)
        self.navBox = wx.BoxSizer(wx.VERTICAL)
        self.windowBox = wx.BoxSizer(wx.HORIZONTAL)
        self.titleBox = wx.BoxSizer(wx.HORIZONTAL)

        # ========================= NavBar ================================

        #def setNavigationButtons(self, button, name):

        self.home_btn = GenBitmapButton(
            self, -1, wx.Bitmap(wx.Image("icon/home.png", wx.BITMAP_TYPE_PNG)))
        self.dream_btn = GenBitmapButton(
            self, -1, wx.Bitmap(wx.Image("icon/traum.png",
                                         wx.BITMAP_TYPE_PNG)))
        self.fiveyearplay_btn = GenBitmapButton(
            self, -1,
            wx.Bitmap(wx.Image("icon/5jahresplan.png", wx.BITMAP_TYPE_PNG)))
        self.yearplan_btn = GenBitmapButton(
            self, -1,
            wx.Bitmap(wx.Image("icon/jahresplan.png", wx.BITMAP_TYPE_PNG)))
        self.monthplan_btn = GenBitmapButton(
            self, -1,
            wx.Bitmap(wx.Image("icon/monatsplan.png", wx.BITMAP_TYPE_PNG)))
        self.dayplan_btn = GenBitmapButton(
            self, -1,
            wx.Bitmap(wx.Image("icon/tagesplan.png", wx.BITMAP_TYPE_PNG)))
        self.habittrrack_btn = GenBitmapButton(
            self, -1,
            wx.Bitmap(wx.Image("icon/habittrack.png", wx.BITMAP_TYPE_PNG)))

        self.home_btn.SetToolTip("Home")
        self.dream_btn.SetToolTip("Traum")
        self.fiveyearplay_btn.SetToolTip("5-Jahresplan")
        self.yearplan_btn.SetToolTip("Jahresplan")
        self.monthplan_btn.SetToolTip("Monatsüberblick")
        self.dayplan_btn.SetToolTip("Tagesübersicht")
        self.habittrrack_btn.SetToolTip("Habittracker")

        self.home_btn.SetBitmapSelected(
            wx.Bitmap(wx.Image("icon/home_selected.png", wx.BITMAP_TYPE_PNG)))
        self.dream_btn.SetBitmapSelected(
            wx.Bitmap(wx.Image("icon/traum_selected.png", wx.BITMAP_TYPE_PNG)))
        self.fiveyearplay_btn.SetBitmapSelected(
            wx.Bitmap(
                wx.Image("icon/5jahresplan_selected.png", wx.BITMAP_TYPE_PNG)))
        self.yearplan_btn.SetBitmapSelected(
            wx.Bitmap(
                wx.Image("icon/jahresplan_selected.png", wx.BITMAP_TYPE_PNG)))
        self.monthplan_btn.SetBitmapSelected(
            wx.Bitmap(
                wx.Image("icon/monatsplan_selected.png", wx.BITMAP_TYPE_PNG)))
        self.dayplan_btn.SetBitmapSelected(
            wx.Bitmap(
                wx.Image("icon/tagesplan_selected.png", wx.BITMAP_TYPE_PNG)))
        self.habittrrack_btn.SetBitmapSelected(
            wx.Bitmap(
                wx.Image("icon/habittrack_selected.png", wx.BITMAP_TYPE_PNG)))

        self.home_btn.SetBitmapFocus(
            wx.Bitmap(wx.Image("icon/home_focus.png", wx.BITMAP_TYPE_PNG)))
        self.dream_btn.SetBitmapFocus(
            wx.Bitmap(wx.Image("icon/traum_focus.png", wx.BITMAP_TYPE_PNG)))
        self.fiveyearplay_btn.SetBitmapFocus(
            wx.Bitmap(
                wx.Image("icon/5jahresplan_focus.png", wx.BITMAP_TYPE_PNG)))
        self.yearplan_btn.SetBitmapFocus(
            wx.Bitmap(wx.Image("icon/jahresplan_focus.png",
                               wx.BITMAP_TYPE_PNG)))
        self.monthplan_btn.SetBitmapFocus(
            wx.Bitmap(wx.Image("icon/monatsplan_focus.png",
                               wx.BITMAP_TYPE_PNG)))
        self.dayplan_btn.SetBitmapFocus(
            wx.Bitmap(wx.Image("icon/tagesplan_focus.png",
                               wx.BITMAP_TYPE_PNG)))
        self.habittrrack_btn.SetBitmapFocus(
            wx.Bitmap(wx.Image("icon/habittrack_focus.png",
                               wx.BITMAP_TYPE_PNG)))

        navButtonList = [
            self.home_btn, self.dream_btn, self.fiveyearplay_btn,
            self.yearplan_btn, self.monthplan_btn, self.dayplan_btn,
            self.habittrrack_btn
        ]
        for button in navButtonList:
            self.init_designNavigation(button)

        self.home_btn.Bind(wx.EVT_BUTTON, self.OnHomeClicked)
        self.dream_btn.Bind(wx.EVT_BUTTON, self.OnDreamClicked)
        self.fiveyearplay_btn.Bind(wx.EVT_BUTTON, self.On5YearClicked)
        self.yearplan_btn.Bind(wx.EVT_BUTTON, self.OnYearClicked)
        self.monthplan_btn.Bind(wx.EVT_BUTTON, self.OnMonthClicked)
        self.dayplan_btn.Bind(wx.EVT_BUTTON, self.OnDayClicked)
        self.habittrrack_btn.Bind(wx.EVT_BUTTON, self.OnHabittrackClicked)

        # Fügt die Navigationsbuttons dem Sizer hinzu
        for buttons in navButtonList:
            self.navBox.Add(buttons, 1, wx.ALL, self.border)

        self.navBox.AddStretchSpacer(3)

        # ========================= TitleBar ================================
        look = wx.Panel(self)

        font_dayHeader = wx.Font(28, fontfamily, wx.FONTSTYLE_NORMAL,
                                 wx.FONTWEIGHT_BOLD, False, schriftart)
        if int(aktuellerTag) < 10:
            titleBox_day = "  " + "0" + aktuellerTag + " " + self.getWeekday()
        else:
            titleBox_day = aktuellerTag + " " + self.getWeekday()
        dayHeader = wx.StaticText(self, 1, titleBox_day)
        dayHeader.SetFont(font_dayHeader)
        dayHeader.SetForegroundColour(wx.Colour(c_hell))

        font_monthHeader = wx.Font(12, wx.FONTFAMILY_SWISS, wx.NORMAL,
                                   wx.FONTWEIGHT_LIGHT, False, "Verdana")
        monthHeader = wx.StaticText(self, 1, self.getMonth())
        monthHeader.SetFont(font_monthHeader)
        monthHeader.SetForegroundColour(wx.Colour(c_hell))

        self.close_btn = GenBitmapButton(
            self, -1, wx.Bitmap(wx.Image("icon/close.png",
                                         wx.BITMAP_TYPE_PNG)), (-1, -1),
            (65, -1))
        self.close_btn.SetToolTip("Beenden")
        self.close_btn.Bind(wx.EVT_BUTTON, self.OnCloseClicked)
        self.init_designNavigation(self.close_btn)
        self.close_btn.SetBitmapSelected(
            wx.Bitmap(wx.Image("icon/close_selected.png", wx.BITMAP_TYPE_PNG)))
        self.close_btn.SetBitmapFocus(
            wx.Bitmap(wx.Image("icon/close_focus.png", wx.BITMAP_TYPE_PNG)))

        self.titleBox.AddSpacer(50)
        self.titleBox.Add(dayHeader, wx.EXPAND | wx.ALL, wx.ALIGN_CENTER)
        self.titleBox.Add(monthHeader, wx.EXPAND | wx.ALL, wx.ALIGN_CENTER)
        self.titleBox.Add(self.close_btn, wx.ALL, wx.ALIGN_CENTER, 10)

        # ========================= MainWindow ================================
        self.windowBox.Add(self.navBox, -1, wx.EXPAND | wx.ALL)
        self.windowBox.Add(self.page_home, 10, wx.EXPAND | wx.ALL)
        self.mainBox.Add(self.titleBox, -1, wx.EXPAND | wx.ALL)
        self.mainBox.Add(self.windowBox, 10, wx.EXPAND | wx.ALL)

        self.SetSizer(self.mainBox)

    # ========================= Methoden ================================
    def init_designNavigation(self, button):
        # Function for simplifying ButtonDesign
        button.SetBezelWidth(0)
        button.SetUseFocusIndicator(False)
        button.SetBackgroundColour(c_dunkel)

    def getWeekday(self):
        switcher = {
            0: "MO",
            1: "DI",
            2: "MI",
            3: "DO",
            4: "FR",
            5: "SA",
            6: "SO"
        }
        return switcher.get(datetime.datetime.today().weekday(),
                            "Ungültiger Tag")

    def getMonth(self):
        switcher = {
            1: "Januar",
            2: "Februar",
            3: "März",
            4: "April",
            5: "Mai",
            6: "Juni",
            7: "Juli",
            8: "August",
            9: "September",
            10: "Oktober",
            11: "November",
            12: "Dezember"
        }
        return switcher.get(int(aktuellerMonat), "Ungültiger Monat")

    # Event Handler for Navigation
    def OnHomeClicked(self, e):

        print("Home gedrückt")

    def OnDreamClicked(self, e):

        print("Traum gedrückt")

    def On5YearClicked(self, e):

        print("5-Jahresplan gedrückt")

    def OnYearClicked(self, e):

        print("Jahresplan gedrückt")

    def OnMonthClicked(self, e):

        print("Monatsplan gedrückt")

    def OnDayClicked(self, e):

        print("Tagesplan gedrückt")

    def OnHabittrackClicked(self, e):

        print("Habittrack gedrückt")

    def OnCloseClicked(self, e):
        self.Destroy()

    # Main Pages
    class Home(wx.Panel):
        def __init__(self, parent):
            super().__init__(parent)
            self.SetBackgroundColour(c_hell)

    class TraumSeite(wx.Panel):
        def __init__(self, parent):
            super().__init__(parent)
            self.SetBackgroundColour(c_hell)

    class FuenfJahresPlanSeite(wx.Panel):
        def __init__(self, parent):
            super().__init__(parent)
            self.SetBackgroundColour(c_hell)

    class JahresSeite(wx.Panel):
        def __init__(self, parent):
            super().__init__(parent)
            self.SetBackgroundColour(c_hell)

    class MonatsSeite(wx.Panel):
        def __init__(self, parent):
            super().__init__(parent)
            self.SetBackgroundColour(c_hell)

    class TagesSeite(wx.Panel):
        def __init__(self, parent):
            super().__init__(parent)
            self.SetBackgroundColour(c_hell)

    class HabitTracker(wx.Panel):
        def __init__(self, parent):
            super().__init__(parent)
            self.SetBackgroundColour(c_hell)
Esempio n. 19
0
class BaseImplantEditorView(wx.Panel):
    def addMarketViewImage(self, iconFile):
        if iconFile is None:
            return -1
        bitmap = BitmapLoader.getBitmap(iconFile, "icons")
        if bitmap is None:
            return -1
        else:
            return self.availableImplantsImageList.Add(bitmap)

    def __init__(self, parent):
        wx.Panel.__init__(self,
                          parent,
                          id=wx.ID_ANY,
                          pos=wx.DefaultPosition,
                          size=wx.DefaultSize,
                          style=wx.TAB_TRAVERSAL)
        self.SetBackgroundColour(
            wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW))

        pmainSizer = wx.BoxSizer(wx.HORIZONTAL)

        availableSizer = wx.BoxSizer(wx.VERTICAL)

        self.searchBox = SearchBox(self)
        self.itemView = ItemView(self)

        self.itemView.Hide()

        availableSizer.Add(self.searchBox, 0, wx.EXPAND)
        availableSizer.Add(self.itemView, 1, wx.EXPAND)

        self.availableImplantsTree = wx.TreeCtrl(self,
                                                 wx.ID_ANY,
                                                 style=wx.TR_DEFAULT_STYLE
                                                 | wx.TR_HIDE_ROOT)
        root = self.availableRoot = self.availableImplantsTree.AddRoot(
            "Available")
        self.availableImplantsImageList = wx.ImageList(16, 16)
        self.availableImplantsTree.SetImageList(
            self.availableImplantsImageList)

        availableSizer.Add(self.availableImplantsTree, 1, wx.EXPAND)

        pmainSizer.Add(availableSizer, 1, wx.ALL | wx.EXPAND, 5)

        buttonSizer = wx.BoxSizer(wx.VERTICAL)
        buttonSizer.AddStretchSpacer()

        self.btnAdd = GenBitmapButton(self,
                                      wx.ID_ADD,
                                      BitmapLoader.getBitmap(
                                          "fit_add_small", "gui"),
                                      style=wx.BORDER_NONE)
        buttonSizer.Add(self.btnAdd, 0)

        self.btnRemove = GenBitmapButton(self,
                                         wx.ID_REMOVE,
                                         BitmapLoader.getBitmap(
                                             "fit_delete_small", "gui"),
                                         style=wx.BORDER_NONE)
        buttonSizer.Add(self.btnRemove, 0)

        buttonSizer.AddStretchSpacer()
        pmainSizer.Add(buttonSizer, 0, wx.EXPAND, 0)

        characterImplantSizer = wx.BoxSizer(wx.VERTICAL)
        self.pluggedImplantsTree = AvailableImplantsView(self)
        characterImplantSizer.Add(self.pluggedImplantsTree, 1,
                                  wx.ALL | wx.EXPAND, 5)
        pmainSizer.Add(characterImplantSizer, 1, wx.EXPAND, 5)

        self.SetSizer(pmainSizer)

        self.hoveredLeftTreeTypeID = None
        self.hoveredRightListRow = None

        # Populate the market tree
        sMkt = Market.getInstance()
        for mktGrp in sMkt.getImplantTree():
            iconId = self.addMarketViewImage(sMkt.getIconByMarketGroup(mktGrp))
            childId = self.availableImplantsTree.AppendItem(root,
                                                            mktGrp.name,
                                                            iconId,
                                                            data=mktGrp.ID)
            if sMkt.marketGroupHasTypesCheck(mktGrp) is False:
                self.availableImplantsTree.AppendItem(childId, "dummy")

        self.availableImplantsTree.SortChildren(self.availableRoot)

        # Bind the event to replace dummies by real data
        self.availableImplantsTree.Bind(wx.EVT_TREE_ITEM_EXPANDING,
                                        self.expandLookup)
        self.availableImplantsTree.Bind(wx.EVT_TREE_ITEM_ACTIVATED,
                                        self.itemSelected)
        self.availableImplantsTree.Bind(wx.EVT_MOTION,
                                        self.OnLeftTreeMouseMove)
        self.availableImplantsTree.Bind(wx.EVT_LEAVE_WINDOW,
                                        self.OnLeftTreeMouseLeave)

        self.itemView.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.itemSelected)

        self.pluggedImplantsTree.Bind(wx.EVT_MOTION, self.OnRightListMouseMove)

        # Bind add & remove buttons
        self.btnAdd.Bind(wx.EVT_BUTTON, self.itemSelected)
        self.btnRemove.Bind(wx.EVT_BUTTON, self.removeItem)

        # We update with an empty list first to set the initial size for Layout(), then update later with actual
        # implants for character. This helps with sizing issues.
        self.pluggedImplantsTree.update([])
        self.bindContext()
        self.Layout()

        self.update()

    def bindContext(self):
        # Binds self.contextChanged to whatever changes the context
        raise NotImplementedError()

    def getImplantsFromContext(self):
        """ Gets list of implants from current context """
        raise NotImplementedError()

    def addImplantToContext(self, item):
        """ Adds implant to the current context"""
        raise NotImplementedError()

    def removeImplantFromContext(self, implant):
        """ Removes implant from the current context"""
        raise NotImplementedError()

    def update(self):
        """Updates implant list based off the current context"""
        self.implants = self.getImplantsFromContext()[:]
        self.implants.sort(
            key=lambda i: int(i.getModifiedItemAttr("implantness")))
        self.pluggedImplantsTree.update(self.implants)

    def contextChanged(self, event):
        self.update()
        event.Skip()

    def expandLookup(self, event):
        tree = self.availableImplantsTree
        sMkt = Market.getInstance()
        parent = event.Item
        child, _ = tree.GetFirstChild(parent)
        text = tree.GetItemText(child)

        if text == "dummy" or text == "itemdummy":
            tree.Delete(child)

        # if the dummy item is a market group, replace with actual market groups
        if text == "dummy":
            # Add 'real stoof!' instead
            currentMktGrp = sMkt.getMarketGroup(tree.GetItemData(parent),
                                                eager="children")
            for childMktGrp in sMkt.getMarketGroupChildren(currentMktGrp):
                iconId = self.addMarketViewImage(
                    sMkt.getIconByMarketGroup(childMktGrp))
                childId = tree.AppendItem(parent,
                                          childMktGrp.name,
                                          iconId,
                                          data=childMktGrp.ID)
                if sMkt.marketGroupHasTypesCheck(childMktGrp) is False:
                    tree.AppendItem(childId, "dummy")
                else:
                    tree.AppendItem(childId, "itemdummy")

        # replace dummy with actual items
        if text == "itemdummy":
            currentMktGrp = sMkt.getMarketGroup(tree.GetItemData(parent))
            items = sMkt.getItemsByMarketGroup(currentMktGrp)
            for item in items:
                iconId = self.addMarketViewImage(item.iconID)
                tree.AppendItem(parent, item.name, iconId, data=item)

        tree.SortChildren(parent)

    def itemSelected(self, event):
        if event.EventObject is self.btnAdd:
            # janky fix that sets EventObject so that we don't have similar code elsewhere.
            if self.itemView.IsShown():
                event.EventObject = self.itemView
            else:
                event.EventObject = self.availableImplantsTree

        if event.EventObject is self.itemView:
            curr = event.EventObject.GetFirstSelected()

            while curr != -1:
                item = self.itemView.items[curr]
                self.addImplantToContext(item)

                curr = event.EventObject.GetNextSelected(curr)
        else:
            root = self.availableImplantsTree.GetSelection()

            if not root.IsOk():
                return

            nchilds = self.availableImplantsTree.GetChildrenCount(root)
            if nchilds == 0:
                item = self.availableImplantsTree.GetItemData(root)
                self.addImplantToContext(item)
            else:
                event.Skip()
                return

        self.update()

    def removeItem(self, event):
        pos = self.pluggedImplantsTree.GetFirstSelected()
        if pos != -1:
            self.removeImplantFromContext(self.implants[pos])
            self.update()

    # Due to https://github.com/wxWidgets/Phoenix/issues/1372 we cannot set tooltips on
    # tree itself; work this around with following two methods, by setting tooltip to
    # parent window
    def OnLeftTreeMouseMove(self, event):
        event.Skip()
        treeItemId, _ = self.availableImplantsTree.HitTest(event.Position)
        if not treeItemId:
            if self.hoveredLeftTreeTypeID is not None:
                self.hoveredLeftTreeTypeID = None
                self.SetToolTip(None)
            return
        item = self.availableImplantsTree.GetItemData(treeItemId)
        isImplant = getattr(item, 'isImplant', False)
        if not isImplant:
            if self.hoveredLeftTreeTypeID is not None:
                self.hoveredLeftTreeTypeID = None
                self.SetToolTip(None)
            return
        if self.hoveredLeftTreeTypeID == item.ID:
            return
        if self.ToolTip is not None:
            self.SetToolTip(None)
        else:
            self.hoveredLeftTreeTypeID = item.ID
            toolTip = wx.ToolTip(stripHtml(item.description))
            toolTip.SetMaxWidth(self.GetSize().Width)
            self.SetToolTip(toolTip)

    def OnLeftTreeMouseLeave(self, event):
        event.Skip()
        self.SetToolTip(None)

    def OnRightListMouseMove(self, event):
        event.Skip()
        row, _, col = self.pluggedImplantsTree.HitTestSubItem(event.Position)
        if row != self.hoveredRightListRow:
            if self.pluggedImplantsTree.ToolTip is not None:
                self.pluggedImplantsTree.SetToolTip(None)
            else:
                self.hoveredRightListRow = row
                try:
                    implant = self.implants[row]
                except IndexError:
                    self.pluggedImplantsTree.SetToolTip(None)
                else:
                    toolTip = wx.ToolTip(stripHtml(implant.item.description))
                    toolTip.SetMaxWidth(
                        self.pluggedImplantsTree.GetSize().Width)
                    self.pluggedImplantsTree.SetToolTip(toolTip)
Esempio n. 20
0
    def InitUI(self):

        # Initializing different MainPages
        self.page_home = self.Home(self)
        self.page_traum = self.TraumSeite(self)
        self.page_fuenfJahresPlan = self.FuenfJahresPlanSeite(self)
        self.page_jahresplan = self.JahresSeite(self)
        self.page_monatsplan = self.MonatsSeite(self)
        self.page_tagesplan = self.TagesSeite(self)
        self.page_habittracker = self.HabitTracker(self)

        self.border = 5

        # creating main-structure
        self.mainBox = wx.BoxSizer(wx.VERTICAL)
        self.navBox = wx.BoxSizer(wx.VERTICAL)
        self.windowBox = wx.BoxSizer(wx.HORIZONTAL)
        self.titleBox = wx.BoxSizer(wx.HORIZONTAL)

        # ========================= NavBar ================================

        #def setNavigationButtons(self, button, name):

        self.home_btn = GenBitmapButton(
            self, -1, wx.Bitmap(wx.Image("icon/home.png", wx.BITMAP_TYPE_PNG)))
        self.dream_btn = GenBitmapButton(
            self, -1, wx.Bitmap(wx.Image("icon/traum.png",
                                         wx.BITMAP_TYPE_PNG)))
        self.fiveyearplay_btn = GenBitmapButton(
            self, -1,
            wx.Bitmap(wx.Image("icon/5jahresplan.png", wx.BITMAP_TYPE_PNG)))
        self.yearplan_btn = GenBitmapButton(
            self, -1,
            wx.Bitmap(wx.Image("icon/jahresplan.png", wx.BITMAP_TYPE_PNG)))
        self.monthplan_btn = GenBitmapButton(
            self, -1,
            wx.Bitmap(wx.Image("icon/monatsplan.png", wx.BITMAP_TYPE_PNG)))
        self.dayplan_btn = GenBitmapButton(
            self, -1,
            wx.Bitmap(wx.Image("icon/tagesplan.png", wx.BITMAP_TYPE_PNG)))
        self.habittrrack_btn = GenBitmapButton(
            self, -1,
            wx.Bitmap(wx.Image("icon/habittrack.png", wx.BITMAP_TYPE_PNG)))

        self.home_btn.SetToolTip("Home")
        self.dream_btn.SetToolTip("Traum")
        self.fiveyearplay_btn.SetToolTip("5-Jahresplan")
        self.yearplan_btn.SetToolTip("Jahresplan")
        self.monthplan_btn.SetToolTip("Monatsüberblick")
        self.dayplan_btn.SetToolTip("Tagesübersicht")
        self.habittrrack_btn.SetToolTip("Habittracker")

        self.home_btn.SetBitmapSelected(
            wx.Bitmap(wx.Image("icon/home_selected.png", wx.BITMAP_TYPE_PNG)))
        self.dream_btn.SetBitmapSelected(
            wx.Bitmap(wx.Image("icon/traum_selected.png", wx.BITMAP_TYPE_PNG)))
        self.fiveyearplay_btn.SetBitmapSelected(
            wx.Bitmap(
                wx.Image("icon/5jahresplan_selected.png", wx.BITMAP_TYPE_PNG)))
        self.yearplan_btn.SetBitmapSelected(
            wx.Bitmap(
                wx.Image("icon/jahresplan_selected.png", wx.BITMAP_TYPE_PNG)))
        self.monthplan_btn.SetBitmapSelected(
            wx.Bitmap(
                wx.Image("icon/monatsplan_selected.png", wx.BITMAP_TYPE_PNG)))
        self.dayplan_btn.SetBitmapSelected(
            wx.Bitmap(
                wx.Image("icon/tagesplan_selected.png", wx.BITMAP_TYPE_PNG)))
        self.habittrrack_btn.SetBitmapSelected(
            wx.Bitmap(
                wx.Image("icon/habittrack_selected.png", wx.BITMAP_TYPE_PNG)))

        self.home_btn.SetBitmapFocus(
            wx.Bitmap(wx.Image("icon/home_focus.png", wx.BITMAP_TYPE_PNG)))
        self.dream_btn.SetBitmapFocus(
            wx.Bitmap(wx.Image("icon/traum_focus.png", wx.BITMAP_TYPE_PNG)))
        self.fiveyearplay_btn.SetBitmapFocus(
            wx.Bitmap(
                wx.Image("icon/5jahresplan_focus.png", wx.BITMAP_TYPE_PNG)))
        self.yearplan_btn.SetBitmapFocus(
            wx.Bitmap(wx.Image("icon/jahresplan_focus.png",
                               wx.BITMAP_TYPE_PNG)))
        self.monthplan_btn.SetBitmapFocus(
            wx.Bitmap(wx.Image("icon/monatsplan_focus.png",
                               wx.BITMAP_TYPE_PNG)))
        self.dayplan_btn.SetBitmapFocus(
            wx.Bitmap(wx.Image("icon/tagesplan_focus.png",
                               wx.BITMAP_TYPE_PNG)))
        self.habittrrack_btn.SetBitmapFocus(
            wx.Bitmap(wx.Image("icon/habittrack_focus.png",
                               wx.BITMAP_TYPE_PNG)))

        navButtonList = [
            self.home_btn, self.dream_btn, self.fiveyearplay_btn,
            self.yearplan_btn, self.monthplan_btn, self.dayplan_btn,
            self.habittrrack_btn
        ]
        for button in navButtonList:
            self.init_designNavigation(button)

        self.home_btn.Bind(wx.EVT_BUTTON, self.OnHomeClicked)
        self.dream_btn.Bind(wx.EVT_BUTTON, self.OnDreamClicked)
        self.fiveyearplay_btn.Bind(wx.EVT_BUTTON, self.On5YearClicked)
        self.yearplan_btn.Bind(wx.EVT_BUTTON, self.OnYearClicked)
        self.monthplan_btn.Bind(wx.EVT_BUTTON, self.OnMonthClicked)
        self.dayplan_btn.Bind(wx.EVT_BUTTON, self.OnDayClicked)
        self.habittrrack_btn.Bind(wx.EVT_BUTTON, self.OnHabittrackClicked)

        # Fügt die Navigationsbuttons dem Sizer hinzu
        for buttons in navButtonList:
            self.navBox.Add(buttons, 1, wx.ALL, self.border)

        self.navBox.AddStretchSpacer(3)

        # ========================= TitleBar ================================
        look = wx.Panel(self)

        font_dayHeader = wx.Font(28, fontfamily, wx.FONTSTYLE_NORMAL,
                                 wx.FONTWEIGHT_BOLD, False, schriftart)
        if int(aktuellerTag) < 10:
            titleBox_day = "  " + "0" + aktuellerTag + " " + self.getWeekday()
        else:
            titleBox_day = aktuellerTag + " " + self.getWeekday()
        dayHeader = wx.StaticText(self, 1, titleBox_day)
        dayHeader.SetFont(font_dayHeader)
        dayHeader.SetForegroundColour(wx.Colour(c_hell))

        font_monthHeader = wx.Font(12, wx.FONTFAMILY_SWISS, wx.NORMAL,
                                   wx.FONTWEIGHT_LIGHT, False, "Verdana")
        monthHeader = wx.StaticText(self, 1, self.getMonth())
        monthHeader.SetFont(font_monthHeader)
        monthHeader.SetForegroundColour(wx.Colour(c_hell))

        self.close_btn = GenBitmapButton(
            self, -1, wx.Bitmap(wx.Image("icon/close.png",
                                         wx.BITMAP_TYPE_PNG)), (-1, -1),
            (65, -1))
        self.close_btn.SetToolTip("Beenden")
        self.close_btn.Bind(wx.EVT_BUTTON, self.OnCloseClicked)
        self.init_designNavigation(self.close_btn)
        self.close_btn.SetBitmapSelected(
            wx.Bitmap(wx.Image("icon/close_selected.png", wx.BITMAP_TYPE_PNG)))
        self.close_btn.SetBitmapFocus(
            wx.Bitmap(wx.Image("icon/close_focus.png", wx.BITMAP_TYPE_PNG)))

        self.titleBox.AddSpacer(50)
        self.titleBox.Add(dayHeader, wx.EXPAND | wx.ALL, wx.ALIGN_CENTER)
        self.titleBox.Add(monthHeader, wx.EXPAND | wx.ALL, wx.ALIGN_CENTER)
        self.titleBox.Add(self.close_btn, wx.ALL, wx.ALIGN_CENTER, 10)

        # ========================= MainWindow ================================
        self.windowBox.Add(self.navBox, -1, wx.EXPAND | wx.ALL)
        self.windowBox.Add(self.page_home, 10, wx.EXPAND | wx.ALL)
        self.mainBox.Add(self.titleBox, -1, wx.EXPAND | wx.ALL)
        self.mainBox.Add(self.windowBox, 10, wx.EXPAND | wx.ALL)

        self.SetSizer(self.mainBox)
Esempio n. 21
0
    def __init__(self, parent):
        wx.Panel.__init__(self,
                          parent,
                          id=wx.ID_ANY,
                          pos=wx.DefaultPosition,
                          size=wx.DefaultSize,
                          style=wx.TAB_TRAVERSAL)
        self.SetBackgroundColour(
            wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW))

        pmainSizer = wx.BoxSizer(wx.HORIZONTAL)

        availableSizer = wx.BoxSizer(wx.VERTICAL)

        self.searchBox = SearchBox(self)
        self.itemView = ItemView(self)

        self.itemView.Hide()

        availableSizer.Add(self.searchBox, 0, wx.EXPAND)
        availableSizer.Add(self.itemView, 1, wx.EXPAND)

        self.availableImplantsTree = wx.TreeCtrl(self,
                                                 wx.ID_ANY,
                                                 style=wx.TR_DEFAULT_STYLE
                                                 | wx.TR_HIDE_ROOT)
        root = self.availableRoot = self.availableImplantsTree.AddRoot(
            "Available")
        self.availableImplantsImageList = wx.ImageList(16, 16)
        self.availableImplantsTree.SetImageList(
            self.availableImplantsImageList)

        availableSizer.Add(self.availableImplantsTree, 1, wx.EXPAND)

        pmainSizer.Add(availableSizer, 1, wx.ALL | wx.EXPAND, 5)

        buttonSizer = wx.BoxSizer(wx.VERTICAL)
        buttonSizer.AddStretchSpacer()

        self.btnAdd = GenBitmapButton(self,
                                      wx.ID_ADD,
                                      BitmapLoader.getBitmap(
                                          "fit_add_small", "gui"),
                                      style=wx.BORDER_NONE)
        buttonSizer.Add(self.btnAdd, 0)

        self.btnRemove = GenBitmapButton(self,
                                         wx.ID_REMOVE,
                                         BitmapLoader.getBitmap(
                                             "fit_delete_small", "gui"),
                                         style=wx.BORDER_NONE)
        buttonSizer.Add(self.btnRemove, 0)

        buttonSizer.AddStretchSpacer()
        pmainSizer.Add(buttonSizer, 0, wx.EXPAND, 0)

        characterImplantSizer = wx.BoxSizer(wx.VERTICAL)
        self.pluggedImplantsTree = AvailableImplantsView(self)
        characterImplantSizer.Add(self.pluggedImplantsTree, 1,
                                  wx.ALL | wx.EXPAND, 5)
        pmainSizer.Add(characterImplantSizer, 1, wx.EXPAND, 5)

        self.SetSizer(pmainSizer)

        self.hoveredLeftTreeTypeID = None
        self.hoveredRightListRow = None

        # Populate the market tree
        sMkt = Market.getInstance()
        for mktGrp in sMkt.getImplantTree():
            iconId = self.addMarketViewImage(sMkt.getIconByMarketGroup(mktGrp))
            childId = self.availableImplantsTree.AppendItem(root,
                                                            mktGrp.name,
                                                            iconId,
                                                            data=mktGrp.ID)
            if sMkt.marketGroupHasTypesCheck(mktGrp) is False:
                self.availableImplantsTree.AppendItem(childId, "dummy")

        self.availableImplantsTree.SortChildren(self.availableRoot)

        # Bind the event to replace dummies by real data
        self.availableImplantsTree.Bind(wx.EVT_TREE_ITEM_EXPANDING,
                                        self.expandLookup)
        self.availableImplantsTree.Bind(wx.EVT_TREE_ITEM_ACTIVATED,
                                        self.itemSelected)
        self.availableImplantsTree.Bind(wx.EVT_MOTION,
                                        self.OnLeftTreeMouseMove)
        self.availableImplantsTree.Bind(wx.EVT_LEAVE_WINDOW,
                                        self.OnLeftTreeMouseLeave)

        self.itemView.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.itemSelected)

        self.pluggedImplantsTree.Bind(wx.EVT_MOTION, self.OnRightListMouseMove)

        # Bind add & remove buttons
        self.btnAdd.Bind(wx.EVT_BUTTON, self.itemSelected)
        self.btnRemove.Bind(wx.EVT_BUTTON, self.removeItem)

        # We update with an empty list first to set the initial size for Layout(), then update later with actual
        # implants for character. This helps with sizing issues.
        self.pluggedImplantsTree.update([])
        self.bindContext()
        self.Layout()

        self.update()
Esempio n. 22
0
    def InitUI(self):

        # creating main-structure
        self.mainBox = wx.BoxSizer(wx.VERTICAL)         # MAINWINDOW = Everything
        self.navBox = wx.BoxSizer(wx.VERTICAL)          # Bar on the Right for Navigation
        self.windowBox = wx.BoxSizer(wx.HORIZONTAL)     # Window Left from the Navbar
        self.titleBox = wx.BoxSizer(wx.HORIZONTAL)      # Bar on Top with Date
        self.contentWindow = wx.BoxSizer(wx.VERTICAL)   # Necessarry for switching different panels in WindowBox

        # Initializing different MainPages (Home,Traum,Jahresplan...)
        self.init_contentPages()
        self.organize_contentPages()

        self.border = 5

        # ========================= NavBar ================================
        #Create NavButtons
        self.home_btn = GenBitmapButton(self, -1,wx.Bitmap(wx.Image("icon/home.png", wx.BITMAP_TYPE_PNG)))
        self.dream_btn = GenBitmapButton(self, -1,wx.Bitmap(wx.Image("icon/traum.png", wx.BITMAP_TYPE_PNG)))
        self.fiveyearplay_btn = GenBitmapButton(self, -1,wx.Bitmap(wx.Image("icon/5jahresplan.png", wx.BITMAP_TYPE_PNG)))
        self.yearplan_btn = GenBitmapButton(self, -1,wx.Bitmap(wx.Image("icon/jahresplan.png", wx.BITMAP_TYPE_PNG)))
        self.monthplan_btn = GenBitmapButton(self, -1,wx.Bitmap(wx.Image("icon/monatsplan.png", wx.BITMAP_TYPE_PNG)))
        self.dayplan_btn = GenBitmapButton(self, -1,wx.Bitmap(wx.Image("icon/tagesplan.png", wx.BITMAP_TYPE_PNG)))
        self.habittrrack_btn = GenBitmapButton(self, -1,wx.Bitmap(wx.Image("icon/habittrack.png", wx.BITMAP_TYPE_PNG)))

        #Storing NavButtonData
        navButtonDict = {
            self.home_btn: "home",
            self.dream_btn: "traum",
            self.fiveyearplay_btn: "5jahresplan",
            self.yearplan_btn: "jahresplan",
            self.monthplan_btn: "monatsplan",
            self.dayplan_btn: "tagesplan",
            self.habittrrack_btn: "habittrack",
        }

        #Design NavButtons
        for button in navButtonDict:
            self.set_NavigationButtons(button, str(navButtonDict[button]))
            self.design_NavigationButtons(button)
            self.navBox.Add(button, 1 , wx.ALL , self.border)
        #Bind NavButtons
        self.bind_NavigationButtons()

        self.navBox.AddStretchSpacer(3)

        # ========================= TitleBar ================================
        look = wx.Panel(self)

        self.close_btn = GenBitmapButton(self, -1,wx.Bitmap(wx.Image("icon/close.png", wx.BITMAP_TYPE_PNG)),(-1,-1),(65,-1))
        self.set_NavigationButtons(self.close_btn, str("close"))
        self.design_NavigationButtons(self.close_btn)
        self.close_btn.Bind(wx.EVT_BUTTON, self.OnCloseClicked)

        font_dayHeader = wx.Font(28, fontfamily, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, schriftart)
        if int(aktuellerTag) < 10:
            titleBox_day = "  " + "0" + aktuellerTag + " " + self.getWeekday()
        else:
            titleBox_day = aktuellerTag + " " + self.getWeekday()
        dayHeader = wx.StaticText(self, 1, titleBox_day)
        dayHeader.SetFont(font_dayHeader)
        dayHeader.SetForegroundColour(wx.Colour(c_hell))

        font_monthHeader = wx.Font(12, wx.FONTFAMILY_SWISS, wx.NORMAL, wx.FONTWEIGHT_LIGHT, False, "Verdana")
        monthHeader = wx.StaticText(self, 1, self.getMonth())
        monthHeader.SetFont(font_monthHeader)
        monthHeader.SetForegroundColour(wx.Colour(c_hell))

        if int(aktuellerTag) > 9:
            self.titleBox.AddSpacer(70)
        else:
            self.titleBox.AddSpacer(50)
        self.titleBox.Add(dayHeader, wx.EXPAND | wx.ALL, wx.ALIGN_CENTER)
        self.titleBox.Add(monthHeader, wx.EXPAND | wx.ALL, wx.ALIGN_CENTER)
        self.titleBox.Add(self.close_btn, wx.ALL, wx.ALIGN_CENTER, 10)

        # ========================= MainWindow ================================

        self.windowBox.Add(self.navBox, -1, wx.EXPAND | wx.ALL)
        self.windowBox.Add(self.contentWindow, 10, wx.EXPAND |wx.ALL)
        self.mainBox.Add(self.titleBox, -1, wx.EXPAND | wx.ALL)
        self.mainBox.Add(self.windowBox, 10, wx.EXPAND | wx.ALL)

        self.SetSizer(self.mainBox)