wxpython 传递信息,指针? [英] wxpython passing information, pointers?

查看:22
本文介绍了wxpython 传递信息,指针?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个应用程序来帮助我跟踪我的学生.基本上是一个定制的笔记本/成绩簿.去年夏天我一起破解了一些在去年有效的东西,但我需要更好的东西.

I'm trying to code up an application to help me keep track of my students. Basically a customized notebook/gradebook. I hacked something together last summer that worked for this past year, but I need something better.

我将从数据库中提取每个学生的记录,将其显示在我的主页上,并让元素可点击以打开一个框架,以便我可以对其进行编辑.我需要在这两个帧之间传递信息,我是个白痴,因为我似乎无法弄清楚如何更改我遇到的显示 lambda 和同级信息传递的示例.

I'm going to pull each students record from a database, display it on my main page and have elements clickable to open a frame so that I can edit it. I need to pass information between these two frames and I'm an idiot because I can't seem to figure out how to alter the examples I've come across showing lambdas and same-class information passing.

在我的主窗口上,我有一个看起来像这样的 StaticText

On my main window I have a StaticText that looks like this

self.q1a_lbl = wx.StaticText(id=wxID_MAINWINDOWQ1A_LBL, label=u'87%',
      name=u'q1a_lbl', parent=self.alg_panel, pos=wx.Point(115, 48),
      size=wx.Size(23, 17), style=0)
self.q1a_lbl.SetToolTipString(u'Date \n\nNotes')
self.q1a_lbl.Bind(wx.EVT_LEFT_UP, self.OnQ1a_lblLeftUp)

然后我有这个功能:

def OnQ1a_lblLeftUp(self, event):
    import quiz_notes
    quiz_notes.create(self).Show(True)

它以图形方式工作,但除了在单击文本时打开一个窗口之外,我并没有真正做任何事情.然后我有另一个框架

Which works graphically, but I'm not really doing anything other than opening a window when the text is clicked on. Then I have another Frame with

import wx

def create(parent):
return quiz_notes(parent)

[wxID_QUIZ_NOTES, wxID_QUIZ_NOTESCANCEL_BTN, wxID_QUIZ_NOTESDATEPICKERCTRL1, 
 wxID_QUIZ_NOTESENTER_BTN, wxID_QUIZ_NOTESPANEL1, wxID_QUIZ_NOTESTEXTCTRL1, 
] = [wx.NewId() for _init_ctrls in range(6)]

class quiz_notes(wx.Frame):
    def _init_ctrls(self, prnt):
...and so on

我想至少传递几个变量.最终,当我开始将数据库集成到其中时,我只会传递一个元组.或者参考它.在 C 中,我只使用一个指针.无论如何,进行更改,然后返回到我的主窗口.简而言之,在这两个类之间处理数据的最佳方式是什么?

I would like to pass at least a couple of variables. Eventually, when I start integrating the database into it, I would just pass a tuple. Or a reference to it. In C I'd just use a pointer. Anyway, make changes and then go back to my main window. In short, whats the best way to work with data between these two classes?

推荐答案

查看 Mike Driscoll 的 关于在 wxPython 中使用 PubSub 的博文.

Check out Mike Driscoll's blog post on using PubSub in wxPython.

它使用 wxPython 中包含的 PubSub - 请注意它是一个独立库,并且最新版本的 API 与 wx 中包含的不同(更好的 API,如果我可以这么说)

It's using the included PubSub in wxPython - just be aware that it is a stand-alone library, and the latest version's API is different to the one included in wx (a better API, if I may say so)

这篇关于wxpython 传递信息,指针?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆