时间:2021-05-22
本文实例为大家分享了wxpython绘制圆角窗体的具体代码,供大家参考,具体内容如下
# -*- coding:gbk -*- import wx class RCDialog(wx.Dialog): def __init__(self,parent=None,size=wx.DefaultSize): wx.Dialog.__init__(self, parent, -1, size=size, style=wx.FRAME_SHAPED | wx.SIMPLE_BORDER | wx.FRAME_NO_TASKBAR | wx.STAY_ON_TOP) self.Centre( wx.BOTH) # linux平台 if wx.Platform == "__WXGTK__": self.Bind(wx.EVT_WINDOW_CREATE, self.SetBalloonShape) else: self.SetBalloonShape() self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) self.Bind(wx.EVT_MOTION, self.OnMouseMove) self.Bind(wx.EVT_RIGHT_UP, self.OnRightUp) def OnLeftDown(self, event): pos = event.GetPosition() x, y = self.ClientToScreen(event.GetPosition()) ox, oy = self.GetPosition() dx = x - ox dy = y - oy self.delta = ((dx, dy)) def OnMouseMove(self, event): if event.Dragging() and event.LeftIsDown(): x, y = self.ClientToScreen(event.GetPosition()) fp = (x - self.delta[0], y - self.delta[1]) self.Move(fp) def OnRightUp(self, evt): self.Close() def SetBalloonShape(self, event=None): width, height = self.GetSize() bmp = wx.EmptyBitmap(width,height) dc = wx.BufferedDC(None, bmp) dc.BeginDrawing() dc.SetBackground(wx.Brush(wx.Colour(0,0,0), wx.SOLID)) dc.Clear() dc.DrawRoundedRectangle(0, 0, width-1, height-1, 4) dc.EndDrawing() r = wx.RegionFromBitmapColour(bmp, wx.Colour(0,0,0)) self.hasShape = self.SetShape(r) if __name__ == "__main__": app = wx.PySimpleApp() dlg = RCDialog(size=(376,282)) dlg.Show() app.MainLoop()以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
1、如果制作圆角窗体,窗体先继承DOTNETBAR的:publicpartialclassForm2:DevComponents.DotNetBar.Offic
使用Matplotlib在wxPython的Panel上绘制曲线图,需要导入:importnumpyfrommatplotlib.backends.backen
1,导入wxpython库importwx2,建立窗体构造类class名字(wx.Frame):def__init__(self,parent,id):wx.F
网上看到的很多winform窗体圆角设计代码都比较累赘,这里分享一个少量代码就可以实现的圆角。主要运用了System.Drawing.Drawing2D。效果图
电脑自带的画图工具想要绘制圆角矩形,该怎么绘制圆角矩形呢?下面我们就来看看详细的教程。软件名称:xp画图工具(xp自带的画图工具)绿色单文件版软件大小:135K