def _change_value(self, snbt: SNBTType, snbt_text: wx.StaticText): try: nbt = amulet_nbt.from_snbt(snbt) except: snbt_text.SetLabel("Invalid SNBT") snbt_text.SetBackgroundColour((255, 200, 200)) else: if isinstance(nbt, PropertyDataTypes): snbt_text.SetLabel(nbt.to_snbt()) snbt_text.SetBackgroundColour(wx.NullColour) else: snbt_text.SetLabel(f"{nbt.__class__.__name__} not valid") snbt_text.SetBackgroundColour((255, 200, 200)) self.Layout()
def CreateCenterSection(self): sizer = wx.BoxSizer(orient=wx.VERTICAL) top = wx.BoxSizer(orient=wx.HORIZONTAL) submit_button = wx.Button(self, label="Search", size=wx.Size(10, 30)) submit_button.Bind(wx.EVT_BUTTON, self.SearchFieldInput) searchField = TextCtrl(self, size=wx.Size(250, 30)) #searchField.Bind(wx.EVT_KEY_UP, self.SearchFieldInput) searchField.SetFont(self.APPFONT) searchField.SetHint("Search for a card name here") searchField.SetFocus() cardInfo = StaticText( self, label="No card selected", size=wx.Size(250, 500)) cardInfo.SetFont(self.APPFONT) cardInfo.SetBackgroundColour("white") self.cardInfo = cardInfo self.searchField = searchField top.Add(searchField, 2, wx.EXPAND, 1) top.Add(submit_button, 1, wx.EXPAND, 5) sizer.Add(top, 0, wx.EXPAND, 1) sizer.Add(cardInfo, 0, wx.EXPAND, 10) sizer.SetSizeHints(self) self.centerSizer = sizer return sizer
def CreateRightSection(self): rightPanel = wx.BoxSizer(orient=wx.VERTICAL) label = StaticText( self, -1, label="Press on a result to show the card", style=wx.ALIGN_CENTER_HORIZONTAL) label.SetBackgroundColour('white') label.SetFont(self.APPFONT) resultList = ListBox(self) # moreText.SetFont(font) resultList.SetFont(self.APPFONTSMAL) resultList.Bind(wx.EVT_LISTBOX, self.ResultClick) self.resultList = resultList rightPanel.Add(label, 1, wx.EXPAND, 0) rightPanel.Add(resultList, 20, wx.EXPAND, 0) rightPanel.SetSizeHints(self) return rightPanel