[英]Ubuntu Quickly PyGTK and Glade3
我已经使用Ubuntu几年了,一直在寻找Ubuntu下的开发环境来做我一段时间以来想做的事情。 至少可以说很难找到我感到满意的集成环境。 然后,最近我迅速发现了Ubuntu,并认为它对Windows MS Access VBA背景的用户特别有用。 所以我试了一下,几天后使用DesktopCouch制作了我的第一个应用程序。
然后,我发现DesktopCouch不再受青睐,但不想在我的小型应用程序中使用SQL,因此决定使用KirbyBase,到目前为止一切顺利。
我有一个很好的转换方法(请参见屏幕截图),但是我一生都无法绕过对话框屏幕。 当我运行应用程序时,将显示图像中的一个,但这并不意味着直到用户单击“添加”或“编辑”按钮。
我一直在尝试使语法在单击按钮三天后无法显示,显示或使对话框窗口可见,但我还是无法获得它。
我尝试将其设置为单独的Ui文件,例如About和Preferences,但这让我更加困惑。
我认为答案可能很明显,但是三天后我需要帮助。 到目前为止,主窗口的代码也已附加,并且在OnAddSlang过程中,我要显示对话框,收集数据或其他方式。
顺便说一句,我也是Python的新手。
多谢您的协助。
迈克尔![ScreenDump
] 1 。
enter code here
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
### BEGIN LICENSE
# This file is in the public domain
### END LICENSE
import sys
import os
import gettext
from gettext import gettext as _
gettext.textdomain('ozslang')
import gtk
import logging
logger = logging.getLogger('ozslang')
from kirbybase import KirbyBase, KBError #Set up KirbyBase Database
from ozslang_lib import Window
from ozslang.AboutOzslangDialog import AboutOzslangDialog
from ozslang.PreferencesOzslangDialog import PreferencesOzslangDialog
from ozslang.EntryOzslangDialog import EntryOzslangDialog
FILE_EXT = "tbl"
# See ozslang_lib.Window.py for more details about how this class works
class OzslangWindow(Window):
__gtype_name__ = "OzslangWindow"
def finish_initializing(self, builder): # pylint: disable=E1002
"""Set up the main window"""
super(OzslangWindow, self).finish_initializing(builder)
self.AboutDialog = AboutOzslangDialog
self.PreferencesDialog = PreferencesOzslangDialog
# Code for other initialization actions should be added here.
# Set up KirbyBase Database - Check if Created if not Create it
# Otherwise Check Read it and Print out Results.
db = KirbyBase()
dbTable = "slang.tbl"
# Table has Record No, Slang, Meaning, Useage, Is Common, Locality and Comment.
# Fields are Integer, String, String, String, Boolean, String and String.
# Check if the table exists.
if os.path.exists('slang.tbl'):
boolIsCreated = True
print boolIsCreated
#recno = db.insert(dbTable, ['Pie Hole', 'Mouth', 'Shut your pie hole', True, 'Australia Wide', 'No Comments 2'])
result = db.select('slang.tbl', ['recno'], ['*'])
print result
barMsg = 'Slang Table is in current directory'
self.statusbar = builder.get_object("statusbar1")
self.statusbar_cid = self.statusbar.get_context_id("Status")
self.statusbar.push(self.statusbar_cid, barMsg)
else:
#If it does not exist in this location, create it.
result = db.create('slang.tbl', ['slang:str', 'meaning:str', 'use:str',
'iscommon:bool', 'locality:str', 'comment:str'])
print 'Slang Table Created'
barMsg = 'Slang Table Created'
self.statusbar = builder.get_object("statusbar1")
self.statusbar_cid = self.statusbar.get_context_id("Status")
self.statusbar.push(self.statusbar_cid, barMsg)
print 'at end of slang table open create'
def on_EditSlang(self, widget):
"""Called when the user wants to edit a wine entry"""
print "In Edit Function"
pass_
def OnAddSlang(self, widget):
print 'In Add Function'
#Called when the use wants to add a slang
EntryOzslangDialog.hasfocus = True
print 'after dialog...'
def on_btnOK_clicked(self,widget):
pass
def on_btnCancel_clicked(self,widget):
pass
def _on_close(self, window):
pass
最终,一旦您知道了秘密,那就很简单了。 我所需要知道的是,该对话框需要通过构建器进行引用,如下所示:
entrydialog = self.builder.get_object("EntryDialog")
entrydialog.hide()
当然,当用户单击添加按钮时,show()选项用于再次显示数据输入窗口。
我知道这是我遇到的一个基本语法问题,但是在其他项目之间断断续续地花了3天的时间,寻找与Ubuntu Quickly,Glade 3.10和PyGtk +有关的答案。 视频中没有一个,也没有示例指向对话框屏幕,并且有不计其数的示例使用早期的Glade版本将UI构建为代码的一部分,但这似乎违反了Glade and Quickly的目的。
我必须说,Galde3和Glade2之间以及与之相关的Gtk材料之间的区别是惊人的,尽管对于Glade3来说很少,但有很多优点,但不足以进一步展示新功能。
无论如何,要感谢腾出的空间,当我拥有完整的App时,我将其写为该站点的示例。
欢呼雀跃-继续努力
迈克尔·亚肯达(Michael Yackandandah)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.