[英]Ubuntu Quickly PyGTK and Glade3
I have been using Ubuntu for several years and have been looking for a development environment under Ubuntu to do some things I have had in mind for a while. 我已经使用Ubuntu几年了,一直在寻找Ubuntu下的开发环境来做我一段时间以来想做的事情。 It has been frustrating to say the least to find an integrated environment I felt comfortable with.
至少可以说很难找到我感到满意的集成环境。 Then recently I discovered Ubuntu Quickly and thought it looked good especially to someone from a Windows MS Access, VBA background.
然后,最近我迅速发现了Ubuntu,并认为它对Windows MS Access VBA背景的用户特别有用。 So I gave it a go and using DesktopCouch turned out my first app after a few days.
所以我试了一下,几天后使用DesktopCouch制作了我的第一个应用程序。
I then found that DesktopCouch is no longer favoured but did not want to go to SQL for my small app and decided to use KirbyBase, all go so far. 然后,我发现DesktopCouch不再受青睐,但不想在我的小型应用程序中使用SQL,因此决定使用KirbyBase,到目前为止一切顺利。
I have go a good way to converting (see screen shot) but for the life of me I can not get my head around dialog screens. 我有一个很好的转换方法(请参见屏幕截图),但是我一生都无法绕过对话框屏幕。 The one in the image displays when I run the app but it is not meant to until the user clicks the add or edit buttons.
当我运行应用程序时,将显示图像中的一个,但这并不意味着直到用户单击“添加”或“编辑”按钮。
I have been trying to get the syntax to show, display or make visible the dialog window when the button is clicked for three days and I just can't get it. 我一直在尝试使语法在单击按钮三天后无法显示,显示或使对话框窗口可见,但我还是无法获得它。
I tried setting it up as a separate Ui file like the About and Preferences but this just confused me more. 我尝试将其设置为单独的Ui文件,例如About和Preferences,但这让我更加困惑。
I think the answer is probable obvious but after three days I need help. 我认为答案可能很明显,但是三天后我需要帮助。 The code for the main window so far is also attached and it is at the OnAddSlang procedure I want to display the dialog, collect the data or otherwise.
到目前为止,主窗口的代码也已附加,并且在OnAddSlang过程中,我要显示对话框,收集数据或其他方式。
By the way I am new to Python as well. 顺便说一句,我也是Python的新手。
Thank you for your assistance in advance. 多谢您的协助。
Michael![ScreenDump 迈克尔![ScreenDump
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
Well in the end it was simple once you know the secret. 最终,一旦您知道了秘密,那就很简单了。 All I needed to know was that the dialog needed to be referenced via the builder as in :
我所需要知道的是,该对话框需要通过构建器进行引用,如下所示:
entrydialog = self.builder.get_object("EntryDialog")
entrydialog.hide()
and of course when the user clicks the add button the show() option is used to display the window again for data input. 当然,当用户单击添加按钮时,show()选项用于再次显示数据输入窗口。
I knew it was a basic syntax problem I had but it has taken over 3 days, off and on between other projects, of searching to find the answer as it relates to Ubuntu Quickly, Glade 3.10 and PyGtk+. 我知道这是我遇到的一个基本语法问题,但是在其他项目之间断断续续地花了3天的时间,寻找与Ubuntu Quickly,Glade 3.10和PyGtk +有关的答案。 None of the video's, or examples addressed dialog screens, and there is a zillion examples of building the UI as part of the code using earlier Glade version but that seemed to defeat the purpose of Glade and Quickly.
视频中没有一个,也没有示例指向对话框屏幕,并且有不计其数的示例使用早期的Glade版本将UI构建为代码的一部分,但这似乎违反了Glade and Quickly的目的。
I must say the difference between Galde3 and Glade2 and the associated Gtk material is amazing, not a lot for Glade3 although the few that there are are good but just not enough to demonstrate a little deeper into the new workings. 我必须说,Galde3和Glade2之间以及与之相关的Gtk材料之间的区别是惊人的,尽管对于Glade3来说很少,但有很多优点,但不足以进一步展示新功能。
Anyway thanks for the space to vent, when I have a finished App I will look at writing it up as a sample for the site. 无论如何,要感谢腾出的空间,当我拥有完整的App时,我将其写为该站点的示例。
Cheers All - Keep up the good work 欢呼雀跃-继续努力
Michael Yackandandah 迈克尔·亚肯达(Michael Yackandandah)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.