I'm new to wxPython, so bear with me I'm setting up a custom GUI and receiving two attributes is required. First of all, I want an interior dweller of a different color (a dark dark border looks very much). Second, I need to bind the dragging attribute so that only allow the label to draw opposite to the whole frame.
Does anyone have a good tutorial on wxPython handling geometry?
Empty Bitmap (W, H) DC = wx.MemoryDC (b) Disitbris (WxkBrush (mask Corner)) DckDrawRectangle (0,0, W, H) Diksiktetbrs ( Wx.Brush (Color shown)) DC SetPen (wx.Pen (color shown)) dc.DrawRoundedRectangle (0,0, w, h, r) d.selectObject (wx.NullBitmap) b.SetMaskColour (mask color) return b def GetRoundShape (w, h, r ): return Wx.RegionFromBitmap (GetRoundBitmap (w, h, r)) category FancyFrame (wx.Frame): def __init __ (self): style = (wx.CLIP_CHILDREN | wx.STAY_ON_TOP | wx.FRAME_NO_TASKBAR | wx.NO_BORDER | Wx.FRAME_SHAPED) Wx.Frame .__ init __ (self, none, title = 'fancy', style = style) self.SetSize (self (250, 40)) Self. Setting ((500,500)) Self. Certification (160 ) Self. Bund (wx. EVT_KEY_UP, self.On_Esc) Self. The rebellion (wx.EVT_MOTION, self. On mouse) itself. Bund (wx.EVT_PAINT, the Lf.OnPaint) If wx.Platform == '__WXGTK__': Swkbind (wx.EVT_WINDOW_CREATE, themselves. Satroundshaip) Other self Ksetroundshaip () itself. Show (True) geo = wx.GridBagSizer () self.label = Wx.StaticText (auto, -1, label = u'Hello! ') Geo.Add (self.label, (0,2)) def SetRoundShape (self , Event = none): w, h = self.GetSizeTuple () self .SetShape (GetRoundShape (w, h, 10)) def OnPaint (auto, event): DC = wx.PaintDC (auto) DC = wx.GCDC (DC) w, h = self.GetSizeTuple () R = 10 DC .SetPen (wx.Pen ( "# 000000", width = 4)) dc.setbrush (wx.brush ( "# 9e9e9e") dc.DrawRoundedRectangle ( 0,0, w, h, r) def On_Esc (auto, event): "" If the user presses the ESC, skip the "escape". Gatecode () == 27: # 27 Escsi is itself closed. (Force = True) Second: Event Skip (), DEF, OnMouse (self, event): "" "" If there is no event, then apply "drag" Dragger NG (): self._dragPos = No Returns Self. CaptureMouse () If not self._dragPos: self._dragPos = event.GetPosition () other: pos = event.GetPosition () displacement = self._dragPos - pos self.SetPosition (own. Getpajhin () - displacement) app = wx.App () f = FancyFrame () app . Main Loop ()
I'm not sure what border you want to change Are you talking about the limit of the selected item? As for dragging objects, I would recommend to look at the Whitperboard, a wxPython drawing program. How to properly select and drag the object and work on Windows and Linux I'm not sure about Mac ...
Comments
Post a Comment