- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
现在我有一个用 wxpython 构建的 GUI,它成功地从 .csv 中提取数据,填充 wx 网格对象,然后将其显示在新框架中。我还成功地让我的主窗口以笔记本样式显示一些信息。我的目标是,当我运行程序时,主页选项卡之一包含与我之前创建的窗口相同的填充网格。一直困扰我的问题是网格创建和网格填充(两个独立的事情)是在不同的类中在不同的(但导入的)本地文件中完成的。此外,我的程序上下文中的以下代码给出了 AttributeError: 'TabPanel' object has no attribute 'con',这是有道理的,但我没有
这是不可能的还是我遗漏了什么(我是否清楚?)?以下是我猜测的相关代码。 (为了方便起见,类和构造函数行的间距不正确。)非常感谢!
标签/笔记本:
class TabPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
self.sizer = wx.BoxSizer(wx.VERTICAL)
txtOne = wx.Panel(Employee.EmployeeViewAllFrame(self).show())
self.sizer.Add(txtOne, 0, wx.ALL , 50)
self.SetSizer(self.sizer)
class NotebookDemo(wx.Notebook):
def __init__(self, parent):
wx.Notebook.__init__(self, parent, id=wx.ID_ANY, style=
wx.BK_DEFAULT
#wx.BK_TOP
#wx.BK_BOTTOM
#wx.BK_LEFT
#wx.BK_RIGHT
)
# Create the first tab and add it to the notebook
tabOne = TabPanel(self)
tabOne.SetBackgroundColour("BLUE")
self.AddPage(tabOne, "Main")
# Create and add the second tab
tabTwo = TabPanel(self)
self.AddPage(tabTwo, "Employees")
# Create and add the third tab
self.AddPage(TabPanel(self), "Tasks")
网格/框架:
class empGrid(wx.grid.Grid):
def __init__(self, parent):
wx.grid.Grid.__init__(self,parent,size = (1500,1000))
self.SetDefaultCellOverflow(False)
self.EnableEditing(False)
self.EnableDragGridSize(False)
self.EnableDragRowSize(False)
self.EnableDragColSize(False)
self.grid = gridlib.Grid(panel2)
self.CreateGrid(TOTALEMPLOYEES, 12)
self.SetColLabelValue(0, "Name")
self.SetColSize(0, 200)
self.SetColLabelValue(1, "Grade")
self.SetColLabelValue(2, "NGID")
self.SetColLabelValue(3, "MyID")
self.SetColLabelValue(4, "Skillset1")
self.SetColSize(4, 110)
self.SetColLabelValue(5, "Skillset2")
self.SetColSize(5, 110)
self.SetColLabelValue(6, "SME")
self.SetColLabelValue(7, "Org")
self.SetColLabelValue(8, "Manager")
self.SetColSize(8, 125)
self.SetColLabelValue(9, "OfficePriority")
self.SetColSize(9, 165)
self.SetColLabelValue(10, "Comments")
self.SetColSize(10, 200)
self.SetColLabelValue(11, "Loan?")
#self.AutoSizeColumns(setAsMin=True)
class EmployeeViewAllFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent,title = 'View All Employees',size=(wx.EXPAND,wx.EXPAND))
self.currentid = ''
self.currentrow = 0
self.parent = parent
#Declare all panels
self.panelMain = wx.Panel(self,size = (1500, 1000))
self.panelSide = wx.Panel(self,size = (wx.EXPAND, 1000))
#self.panelTitle = wx.Panel(self,size = (1000,30))
#self.buttonPanel = wx.Panel(self)
self.buttonExit = wx.Button(self.panelSide, label="exit")
self.buttonExit.Bind(wx.EVT_BUTTON, self.OnExitButton)
cur = self.parent.con.cursor()
cur.execute("SELECT * FROM " + EMPLOYEETABLE + " ORDER BY Name;")
self.rows = cur.fetchall()#Load all the employees into self.rows and organize by name
self.employeenumber = len(self.rows) #Going to be the fetched number from the database
global TOTALEMPLOYEES
TOTALEMPLOYEES = self.employeenumber
#Set up all the column panels and place into an array to be modified
#self.empGrid = empGrid(self.panelMain)
self.empGrid = empGrid(EMP.MainWindow.panel2)
for i in xrange (0, TOTALEMPLOYEES):
self.empGrid.SetRowLabelValue(i, str(i+1))
for j in xrange (0,12):
self.empGrid.SetCellValue(i, j, str(self.rows[i][j]))
if i % 2 == 1:#if it is odd, change the color to make it easier on the eyes
self.empGrid.SetCellBackgroundColour(i, j, 'LIGHT BLUE') #JTEST
self.empGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.OnGridDoubleClick)
self.empGrid.Bind(wx.grid.EVT_GRID_CELL_RIGHT_DCLICK, self.OnGridDoubleClickRight)
#Now do the same thing for the buttons
text = wx.StaticText(self.panelSide, label = "Double left click an employee to modify fields\n\n\n Double right click an employee to add a new employee task" , size = (wx.EXPAND,400))
sideSizer = wx.BoxSizer(wx.VERTICAL)
sideSizer.Add(text)
sideSizer.Add(self.buttonExit)
self.panelSide.SetSizer(sideSizer)
self.panelSide.Layout()
#Put them all together then display
displayEmployeeSizer = wx.BoxSizer(wx.VERTICAL)
displayEmployeeSizer.Add(self.empGrid) #JGRID
self.panelMain.SetSizer(displayEmployeeSizer)
self.panelMain.Layout()
viewEmployeeSizer = wx.BoxSizer(wx.HORIZONTAL)
#viewEmployeeSizer.Add(self.panelTitle,proportion=0)
viewEmployeeSizer.Add(self.panelMain,proportion=0)
viewEmployeeSizer.Add(self.panelSide,proportion = 0)
#viewEmployeeSizer.Add(self.buttonPanel, proportion=0, flag = wx.ALIGN_CENTER_HORIZONTAL)
#viewEmployeeSizer.Add(self.buttonExit, proportion = 0, flag = wx.ALIGN_CENTER_HORIZONTAL)
self.SetSizer(viewEmployeeSizer) #Set the panel size
#self.buttonPanel.Layout()
self.Layout()
self.Show()
最佳答案
您无法在两个不同的父级中显示完全相同的小部件。相反,您需要在创建独立框架时创建 empGrid 的实例,并在创建笔记本时创建不同的实例。
实例化 empGrid 时,将其传递给笔记本面板/页面作为其父级。创建框架时,您将传递框架(或其面板)作为父框架。
关于python - wxpython:如何使用其他地方创建的网格填充笔记本选项卡?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24638269/
问题:将具有两个字符分隔符的数据文件加载到 Azure SQL Db 时,我们遇到以下错误。我们可能做错了什么以及如何解决这个问题? 在 Azure Databricks 中使用 Python 笔记本
我正在使用 ipython notebook 迈出第一步,我成功地将它安装在我的远程服务器上(通过 SSH),并使用以下命令启动它: ipython notebook --ip='*' ---pyla
我想知道对于一个网站来说,最好的数据库设计是什么,让用户(假设有 10k 个用户)给自己留下带有日期的注释。用户只能看到自己的笔记。 用户将看到的示例: 2014年9月28日 -去商店 -带狗去散步
我希望没有人会认为这个问题离题。我即将开始探索在 Jupyter 笔记本中使用 C# 内核。我看到有几种选择,有些似乎过时了。我对探索它们并不真正感兴趣,我只是想要一些能够很好地用于演示的东西。目的是
我已经使用此命令在 R 控制台中安装了 Rcpp,该命令直到现在通常用于安装要在 jupyter 笔记本上运行的软件包: install.packages('Rcpp', '/home/user/an
我已经使用更新了 Tornado sudo pip install --upgrade tornado 检查当前版本显示我已经有一个 4.0 以后的版本 找到命令的输出: pip 显示 Tornado
这个问题在这里已经有了答案: How can I share Jupyter notebooks with non-programmers? [closed] (6 个回答) 5年前关闭。 我安装了一
我有一个 IPython 笔记本,我不小心丢弃了一个巨大的输出 (15 MB),导致笔记本崩溃。现在,当我打开笔记本并尝试删除有问题的单元格时,笔记本又崩溃了——从而阻止了我解决问题并将笔记本恢复到稳
当我使用 ipython 笔记本(Windows 版本)运行任何 %R 代码时,输出在结果之前包含一个 480 x 480 的空白图像。我已经申请了fix #2433让 rmagic 在 Wind
大家好,我想使用新的.NET Jupyter笔记本,因此我准备了一个gitt的存储库,其中包含dockerfile(是正确的)和NuGet.config文件,例如: here the tuto 一切都
如何将本地镜像添加到 IJulia 笔记本?该图像与 IPYNB 文件位于同一本地网络文件夹中。该文件夹可通过符号链接(symbolic link)访问。我尝试过相对文件名和绝对文件名。 ![Ima
docs描述如何创建密码来保护您的 jupyter 笔记本。我希望能够创建并共享一个特定的笔记本,并为该笔记本设置特殊的密码。这可能吗? 最佳答案 不,这是不可能的。该密码保护整个 Jupyter 服
最近我了解到,使用 python 可以生成 IPython 笔记本 automatically .这看起来是个很酷的功能,我想用它来自动生成报告。但是用 julia 而不是 python。那么是否有一
我正在使用 Jupyter 笔记本,并且需要运行另一个 Jupyter 笔记本。这通常使用 %run 很简单,但另一个笔记本的路径是相对的并且包含空格。 这会产生以下错误: %run '..//../
我想在一个循环中运行完整的 Jupyter 笔记本,为笔记本的每次运行传递不同的参数。我可以使用插件传递参数,如下所述:Passing command line arguments to argv i
我真的很感谢这里的一些帮助,基本上我正在学习使用tensorflow,我决定最简单的方法是在VMware和/或Virtualbox上安装ubuntu,然后访问ipython笔记本(anaconda附带
有谁知道在执行单元格之前是否有选项(或建议的 hack)可以让 IPython 笔记本自动保存? 很多时候我一直在做一些事情而没有保存很长一段时间,然后我执行了一个愚蠢的命令,该命令在控制台上打印了如
我正在尝试在另一个文件中运行 .ipynb 文件。我想嵌套这两个的原因是因为在其中一个中,我安装了所有 conda 软件包、github 存储库,并且我不想为我将暂时使用的演示文件重做整个事情。我使用
我有多个相互链接的 Jupyter 笔记本,例如 Notebook1.ipydb 包含指向 Notebook2.ipydb 的链接,其 Markdown [Notebook2](Notebook2.i
我使用 jupyter python 中的 matplotlib 库生成了下图。正如你所看到的,我有两个不同的数据,一个是红色,另一个是绿色。我的问题是,有什么办法可以让我有一个小侧窗来说明每种颜色的
我是一名优秀的程序员,十分优秀!