wxpython grid
构建Grid方法,效果如下:
其它构建grid方法和grid的使用见:还可以见下载资源中的wxpython教程第5章的
gridGeneric.py
gridModel.py
gridNoModel.py
import wx
import wx.grid
import generictable data = (("Bob", "Dernier"), ("Ryne", "Sandberg"),
("Gary", "Matthews"), ("Leon", "Durham"),
("Keith", "Moreland"), ("Ron", "Cey"),
("Jody", "Davis"), ("Larry", "Bowa"),
("Rick", "Sutcliffe")) colLabels = ("Last", "First")
rowLabels = ("CF", "2B", "LF", "1B", "RF", "3B", "C", "SS", "P") class SimpleGrid(wx.grid.Grid):
def __init__(self, parent):
wx.grid.Grid.__init__(self, parent, -1)
tableBase = generictable.GenericTable(data, rowLabels,
colLabels)
self.SetTable(tableBase)
class TestFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, -1, "A Grid",
size=(275, 275))
grid = SimpleGrid(self)
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = TestFrame(None)
frame.Show(True)
app.MainLoop()
grid的简单翻页demo:
效果如下:
源代码:
#!/usr/bin/env <a href="http://lib.csdn.net/base/python" class='replace_word' title="Python知识库" target='_blank' style='color:#df3434; font-weight:bold;'>Python</a>
import wx
class RefactorExample(wx.Frame):
def __init__(self, parent, id):
wx.Frame.__init__(self, parent, id, 'Refactor Example',
size=(340, 200))
panel = wx.Panel(self, -1)
panel.SetBackgroundColour("White")
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
self.createMenuBar()
self.createButtonBar(panel)
self.createTextFields(panel)
def menuData(self):
return (("&File",
("&Open", "Open in status bar", self.OnOpen),
("&Quit", "Quit", self.OnCloseWindow)),
("&Edit",
("&Copy", "Copy", self.OnCopy),
("C&ut", "Cut", self.OnCut),
("&Paste", "Paste", self.OnPaste),
("", "", ""),
("&Options...", "DisplayOptions", self.OnOptions)))
def createMenuBar(self):
menuBar = wx.MenuBar()
for eachMenuData in self.menuData():
menuLabel = eachMenuData[0]
menuItems = eachMenuData[1:]
menuBar.Append(self.createMenu(menuItems), menuLabel)
self.SetMenuBar(menuBar)
def createMenu(self, menuData):
menu = wx.Menu()
for eachLabel, eachStatus, eachHandler in menuData:
if not eachLabel:
menu.AppendSeparator()
continue
menuItem = menu.Append(-1, eachLabel, eachStatus)
self.Bind(wx.EVT_MENU, eachHandler, menuItem)
return menu
def buttonData(self):
return (("First", self.OnFirst),
("<< PREV", self.OnPrev),
("NEXT >>", self.OnNext),
("Last", self.OnLast))
def createButtonBar(self, panel, yPos = 0):
xPos = 0
for eachLabel, eachHandler in self.buttonData():
pos = (xPos, yPos)
button = self.buildOneButton(panel, eachLabel, eachHandler, pos)
xPos += button.GetSize().width
def buildOneButton(self, parent, label, handler, pos=(0,0)):
button = wx.Button(parent, -1, label, pos)
self.Bind(wx.EVT_BUTTON, handler, button)
return button
def textFieldData(self):
return (("First Name", (10, 50)),
("Last Name", (10, 80)))
def createTextFields(self, panel):
for eachLabel, eachPos in self.textFieldData():
self.createCaptionedText(panel, eachLabel, eachPos)
def createCaptionedText(self, panel, label, pos):
static = wx.StaticText(panel, wx.NewId(), label, pos)
static.SetBackgroundColour("White")
textPos = (pos[0] + 75, pos[1])
wx.TextCtrl(panel, wx.NewId(), "", size=(100, -1), pos=textPos)
# Just grouping the empty event handlers together
def OnPrev(self, event): pass
def OnNext(self, event): pass
def OnLast(self, event): pass
def OnFirst(self, event): pass
def OnOpen(self, event): pass
def OnCopy(self, event): pass
def OnCut(self, event): pass
def OnPaste(self, event): pass
def OnOptions(self, event): pass
def OnCloseWindow(self, event):
self.Destroy()
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = RefactorExample(parent=None, id=-1)
frame.Show()
app.MainLoop()
wxpython grid的更多相关文章
- wxPython控件学习之wx.grid.Grid 表格控件
wxPython控件学习之wx.grid.Grid (包括对GridCellEditor和GridCelRender的扩展,以支持更多的grid cell 样式, 以GridCellColorEdit ...
- wxPYTHON图形化软件开发(一)---LOMO工具箱
最近学了wxPYTHON,这次就做了一个工具箱软件练手,软件主要是包含各种小工具,目前想到的有密码管理器,日记本,记账本,今天还看到一个网页浏览器,也可能加进来.目前实现的是密码管理器 软件GUI部分 ...
- wxPython:事件
事件──── 是每个 GUI 应用不可舍割的一部分,因为所有的 GUI 应用程序都是基于事件驱动的.从 GUI 程序启动开始,它就回应同户的不同类型的事件.除了用户,也有其它因素可以产生事件,例如:互 ...
- wxpython 中的所有控件及高级应用
转自http://xoomer.virgilio.it/infinity77/Phoenix/lib.agw.html,,,哈哈终于找到了这块的内容,书上基本没有讲解 This is the Adva ...
- [Python] wxPython 基本控件 (转)
转自:http://www.cnblogs.com/wangjian8888/p/6028777.html 一.静态文本控件 wx.StaticText(parent, id, label, pos= ...
- Python3 tkinter基础 grid(row,column) 窗体的布局
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- 46-wxpython 4 使用 grid 展示表格
转载:https://blog.csdn.net/soslinken/article/details/79024938#%E4%BD%BF%E7%94%A8%E6%A0%B7%E4%BE%8B wxp ...
- Python 模块之wxpython 的应用
第一个应用程序:“Hello World” 作为传统,我们首先将要写一个小的“Hello World”程序,下面是他的代码: #!/usr/bin/env python import wx app = ...
- Python图形界面开发—wxPython库的布局管理及页面切换
前言 wxPython是基于Python的跨平台GUI扩展库,对wxWidgets( C++ 编写)封装实现.GUI程序的开发中界面布局是很重要的一个部分,合理的页面布局能够给予用户良好使用体验.虽然 ...
随机推荐
- 吴裕雄 python 机器学习——密度聚类DBSCAN模型
import numpy as np import matplotlib.pyplot as plt from sklearn import cluster from sklearn.metrics ...
- 比较两种数组随机排序方法的效率 JavaScript版
//比较2中数组随机排序方法的效率 JavaScript版 //randon1思路 //当len=5时候,从0-5中随机3一个放入i=0, // 从0-3随机一个2放入i=2 // 从0-2随机一个1 ...
- Python入门笔记——(2)列表和元组
一.序列 python包含6种内建的序列:列表.元组.字符串.Unicode字符串.buffer对象和xrange对象.序列中每个元素被分配一个序号即索引,第一个索引为0,第二个为1,以此类推.也可以 ...
- UML-2-迭代、进化和敏捷
1.UP UP:Unified Process,统一过程.RUP:Rational Unified Process,Rational 公司制定的UP,是对UP的精细化. UP的过程: 初始 不是需求, ...
- windows 系统C盘暴增
系统: Windows Server 2012R2 问题: C盘200G的空间,暴增剩余3G.但是查看仅有69G的空间占用. 根源:Windows的虚拟文件,驱动器分页. 解决方案: 我的电脑-> ...
- MySQL主从复制,以及双机热备
MySQL数据库自身提供的主从复制功能可以方便的实现数据的多处自动备份,实现数据库的拓展.多个数据备份不仅可以加强数据的安全性,通过实现读写分离还能进一步提升数据库的负载性能. 下图就描述了一个多个数 ...
- mysql explain工具使用
explain工具可以确认执行计划是否良好,查询是否走了合理的索引.查询的执行计划,随着数据的变化也可能会有变化.调用方式:explain + [sql语句]. 另外,explain是有局限性的:1. ...
- oracle 备份恢复篇(五)---rman 剩下控制文件和spfile
一,环境准备 ❤ 拥有全量备份文件
- Maths Intro - Probability
设事件A,B,C两辆独立,且满足ABC=空集,及P(A)=P(B)=P(C)=x,求max(x) x最大值为1/2分析: x值要保证所有的由A.B.C交或并得到的集合的概率测度在0到1之间. 先考虑A ...
- Docker的镜像迁移
[root@localhost ~]# mkdir /opt/soft/ [root@localhost ~]# docker save c3987965c15d > /opt/soft/pos ...