def __init__(self, *args, **kwargs): data, order = kwargs.pop('data') self.settings = kwargs.pop('settings') self.background_color = '#CCCCCC' TransparentAwareFrame.__init__(self, *args, **kwargs) self.SetBackgroundColour(self.background_color) self.Show() self.SetTransparent(self.GetTransparent()) self.Bind(wx.EVT_LEFT_UP, self.OnLeftClick) self.refocus_method = None display_width, display_height = wx.GetDisplaySize() panel = wx.lib.scrolledpanel.ScrolledPanel(self,-1, size=(self.settings.WINDOWWIDTH,display_height), pos=(0,0), style=(wx.NO_BORDER | wx.EXPAND | wx.ALL) ) panel.SetupScrolling() panel.SetBackgroundColour(self.background_color) self.SetTransparent(240) bSizer = wx.BoxSizer( wx.VERTICAL ) self.section_objects = {} for o in order: print o i = data[o]['icon'] curimage = mm_menus.clean_cat_path(i) #icon = wx.Image(curimage, wx.BITMAP_TYPE_ANY).ConvertToBitmap() icon = wx.Image(curimage, wx.BITMAP_TYPE_ANY) icon = icon.Scale(48, 48, wx.IMAGE_QUALITY_HIGH).ConvertToBitmap() #icon = wx.Image(curimage, wx.BITMAP_TYPE_ANY).ConvertToBitmap() #a = GB.GradientButton(panel, -1, icon, o, size = (150,40)) a = CatButton(panel, -1, icon, o, size = (self.settings.BUTTONWIDTH, self.settings.BUTTONHEIGHT)) font = wx.Font(self.settings.FONTSIZE, wx.DEFAULT, wx.NORMAL, wx.BOLD) pencolor = (255,255,255) a.SetFont(font) self.Bind(wx.EVT_BUTTON, self.OnButton, a) a.Show() self.section_objects[o] = a titleSizer = wx.BoxSizer(wx.HORIZONTAL) titleSizer.Add( a, 0, wx.ALL|wx.EXPAND, 5 ) bSizer.Add(titleSizer, 0, wx.EXPAND) panel.SetSizer( bSizer )
def __init__(self, *args, **kwargs): links = kwargs.pop("links") trans = kwargs.pop("trans") self.settings = kwargs.pop("settings") self.mode, self.width = kwargs.pop("mode") TransparentAwareFrame.__init__(self, *args, **kwargs) self.SetBackgroundColour(self.background_color) self.SetTransparent(self.GetTransparent()) display_width, display_height = wx.GetDisplaySize() self.SetTransparent(trans) self.triggers = {} self.section_objects = {} row_size = self.mode x, y = 10, 10 curnum = 0 total = 0 for o in links: print o["title"] i = o["icon"] curimage = mm_menus.clean_cat_path(i) icon = wx.Image(curimage, wx.BITMAP_TYPE_ANY) icon = icon.Scale(64, 64, wx.IMAGE_QUALITY_HIGH).ConvertToBitmap() t = o["title"] # a = GB.GradientButton(self, -1, icon, t, size=(250,72), pos=(x,y), style=wx.DEFAULT) a = LinkButton( self, -1, icon, t, size=(self.settings.BUTTONWIDTH, self.settings.BUTTONHEIGHT), pos=(x, y), style=wx.DEFAULT, settings=self.settings, ) self.Bind(wx.EVT_BUTTON, self.OnButton, a) a.Show() self.triggers[t] = o["command"] x += self.settings.BUTTONWIDTH + self.settings.BUTTONMARGIN # titleSizer.Add( a, 0, wx.ALL, 5 ) curnum += 1 total += 1 if curnum == row_size: y += self.settings.BUTTONHEIGHT + self.settings.BUTTONMARGIN x = self.settings.BUTTONMARGIN # bSizer.Add(titleSizer, 0, wx.EXPAND) # titleSizer = wx.BoxSizer(wx.HORIZONTAL) curnum = 0 # if curnum > 0: # bSizer.Add(titleSizer, 0, wx.EXPAND) if y == self.settings.BUTTONMARGIN: y = self.settings.BUTTONHEIGHT + self.settings.BUTTONMARGIN if curnum > 0 and total % self.mode > 0 and total > 3: y += self.settings.BUTTONHEIGHT + (self.settings.BUTTONMARGIN * 2) if total < self.mode: self.width = (self.settings.BUTTONWIDTH * total) + (self.settings.BUTTONMARGIN * (total + 1)) y += self.settings.BUTTONMARGIN self.SetSize((self.width, y)) self.Show()