def __init__(self): gtk.GtkWindow.__init__(self, gtk.WINDOW_TOPLEVEL) self.set_title("Manhole Interaction") self.set_usize(300,300) self['name'] = "Manhole" vbox = gtk.GtkVBox() pane = gtk.GtkVPaned() self.output = OutputConsole(toplevel=self) pane.pack1(gtkutil.scrollify(self.output), gtk.TRUE, gtk.FALSE) self.input = InputText(toplevel=self) pane.pack2(gtkutil.scrollify(self.input), gtk.FALSE, gtk.TRUE) vbox.pack_start(pane, 1,1,0) self.add(vbox) self.input.grab_focus() self.signal_connect('destroy', gtk.mainquit, None) if _GNOME_POWER: self.display = BrowserDisplay() dWindow = gtk.GtkWindow(title="Spelunking") dWindow.add(self.display) dWindow.show_all() else: self.display = BrowserDisplay(self) # The referencable attached to the Perspective self.client = self self.remote_receiveBrowserObject=self.display.receiveBrowserObject self.remote_console = self.output.console
def __init__(self, size=(300,300), name="Piddle-GTK", infoline=1): """Initialize the canvas and minimal supporting widgets. If |infoline| is true (the default), a status bar will be included at the bottom of the window to support the ,setInfoLine() method. If false, no statusbar will be used. """ import gtk # width, height = (int(round(size[0])), int(round(size[1]))) # top = self.__top = gtk.GtkWindow() vbox = self.__vbox = gtk.GtkVBox() da = gtk.GtkDrawingArea() # top.add(vbox) vbox.pack_start(da) if infoline: sbar = self.__sbar = gtk.GtkStatusbar() vbox.pack_end(sbar, expand=0) sbar.set_border_width(2) else: self.__sbar = None InteractiveCanvas.__init__(self, da, top) top.set_wmclass("canvas", "Canvas") da.realize() da.set_usize(width, height) top.show_all() top.set_icon_name(name) top.set_title(name) self.ensure_size(width, height) self.__status = None
def create_view(name, plines, areas, raster): win = gtk.GtkWindow() win.set_title(name) win.set_policy(gtk.TRUE, gtk.TRUE, gtk.FALSE) shell = gtk.GtkVBox() win.add(shell) view = gview.GvViewArea() view.size(512,512) shell.pack_start(view, expand=gtk.TRUE) if raster: raster_layer = gview.GvRasterLayer(raster) view.add_layer(raster_layer) view.add_layer(gview.GvPqueryLayer()) view.add_layer(gview.GvAreaLayer(areas)) view.add_layer(gview.GvLineLayer(plines)) statusbar = gtk.GtkHBox() shell.pack_start(statusbar, expand=gtk.FALSE) label = gtk.GtkLabel() statusbar.pack_start(label, expand=gtk.FALSE, padding=3) tracker = gview.GvTrackTool(label) tracker.activate(view) view.connect('key-press-event', testmain_button_press) win.show_all() view.grab_focus() win.connect('delete-event', gtk.mainquit) gtk.quit_add_destroy(1, win) return view
def __init__(self, title=None, cols=80, rows=25, font=None): self.win = gtk.GtkWindow() self.win.connect("delete_event", gtk.mainquit) if title is None: title = "ZTerm" if font is None: font = ZTerm.default_font self.win.set_title(title) self.win.set_policy(gtk.FALSE, gtk.TRUE, gtk.TRUE) hbox = gtk.GtkHBox() self.win.add(hbox) hbox.show() term = gnome.zvt.ZvtTerm(cols, rows) term.set_scrollback(500) term.set_font_name(font) term.connect("child_died", child_died_event) hbox.pack_start(term) term.show() self.term = term scroll = gtk.GtkVScrollbar(term.adjustment) hbox.pack_start(scroll, expand=gtk.FALSE) scroll.show() charwidth = term.charwidth charheight = term.charheight self.win.set_geometry_hints(geometry_widget=term, min_width=2*charwidth, min_height=2*charheight, base_width=charwidth, base_height=charheight, width_inc=charwidth, height_inc=charheight) self.win.show()
def warning_window(title, message): win = gtk.GtkWindow() gui["warning_window"] = win win.set_policy(gtk.TRUE, gtk.TRUE, gtk.FALSE) win.set_title(title) win.set_usize(300, -2) win.connect("delete_event", warning_window_close) win.set_border_width(4) window_pos_mode(win) vbox = gtk.GtkVBox(spacing=5) win.add(vbox) vbox.show() label = gtk.GtkLabel("\n\n" + message + "\n\n") set_font(label) label.show() vbox.pack_start(label) button = gtk.GtkButton("Close") button.connect("clicked", warning_window_close) vbox.pack_start(button, expand=gtk.FALSE) button.set_flags(gtk.CAN_DEFAULT) button.grab_default() button.show() gui["main_window"].set_sensitive(gtk.FALSE) gui["warning_window"].show()
def show(self): if not self.currentlyVisible: self.win = w = gtk.GtkWindow(gtk.WINDOW_TOPLEVEL) self.connectid = w.connect("destroy", self.hidden) w.add(self.widget) w.set_title(self.getTitle()) w.show_all() self.entry.grab_focus() self.currentlyVisible = 1
def ShowAboutBox(viewwindow): window = gtk.GtkWindow() window.set_title('About FWTools and OpenEV') vbox = gtk.GtkVBox(homogeneous=FALSE, spacing=15) window.add(vbox) vbox.pack_start( gtk.GtkPixmap(viewwindow, os.path.join(gview.home_dir, 'pics', 'openev.xpm'))) # Contributors contrib = gtk.GtkVBox(homogeneous=FALSE, spacing=3) contrib.pack_start(gtk.GtkLabel('Contributors:')) contrib.pack_start(gtk.GtkLabel('Frank Warmerdam ([email protected]),')) contrib.pack_start( gtk.GtkLabel('Gillian Walter ([email protected]),')) contrib.pack_start( gtk.GtkLabel( 'Peter Farris-Manning ([email protected]),')) contrib.pack_start(gtk.GtkLabel('Paul Spencer ([email protected]),')) contrib.pack_start(gtk.GtkLabel('Steve Rawlinson,')) contrib.pack_start(gtk.GtkLabel('Steve Taylor,')) contrib.pack_start(gtk.GtkLabel('Paul Lahaie,')) contrib.pack_start(gtk.GtkLabel('and others')) vbox.pack_start(contrib) # Funded By funding = gtk.GtkVBox(homogeneous=FALSE, spacing=3) funding.pack_start(gtk.GtkLabel('Funding provided by:')) funding.pack_start( gtk.GtkPixmap(viewwindow, os.path.join(gview.home_dir, 'pics', 'vexcel_logo.xpm'))) funding.pack_start(gtk.GtkLabel('Vexcel Canada Inc.')) funding.pack_start( gtk.GtkPixmap( viewwindow, os.path.join(gview.home_dir, 'pics', 'geo_innovation.xpm'))) funding.pack_start(gtk.GtkLabel('GeoInnovations')) vbox.pack_start(funding) # Other Info other = gtk.GtkVBox(homogeneous=FALSE, spacing=3) FWTOOLS_VERSION = "2.0.6" other.pack_start(gtk.GtkLabel('FWTools ' + FWTOOLS_VERSION)) other.pack_start(gtk.GtkLabel('http://FWTools.MapTools.org')) other.pack_start(gtk.GtkLabel(' ')) other.pack_start(gtk.GtkLabel('OpenEV 1.8')) other.pack_start(gtk.GtkLabel('http://OpenEV.sourceforge.net')) other.pack_start( gtk.GtkLabel('(C) Copyright 2000 Vexcel Canada Inc. www.vexcel.com')) vbox.pack_start(other) window.show_all()
def extension_python_fu_console(): import gtk, gimpenums, gimpshelf stderr.write(str('Hallo' + '\n')) gtk.rc_parse(gimp.gtkrc()) namespace = { '__builtins__': __builtins__, '__name__': '__main__', '__doc__': None, 'gimp': gimp, 'pdb': gimp.pdb, 'shelf': gimpshelf.shelf } for s in gimpenums.__dict__.keys(): if s[0] != '_': namespace[s] = getattr(gimpenums, s) win = gtk.GtkWindow() win.connect("destroy", gtk.mainquit) win.set_title("Gimp-Python Console") cons = gtkcons.Console( namespace=namespace, copyright='Gimp Python Extensions - Copyright (C), 1997-1999' + ' James Henstridge\n', quit_cb=gtk.mainquit) def browse(button, cons): import gtk, pdbbrowse def ok_clicked(button, browse, cons=cons): cons.line.set_text(browse.cmd) browse.destroy() win = pdbbrowse.BrowseWin(ok_button=ok_clicked) win.connect("destroy", gtk.mainquit) win.set_modal(TRUE) win.show() gtk.mainloop() button = gtk.GtkButton("Browse") button.connect("clicked", browse, cons) cons.inputbox.pack_end(button, expand=FALSE) button.show() win.add(cons) cons.show() win.set_default_size(475, 300) win.show() cons.init() # flush the displays every half second def timeout(): gimp.displays_flush() return TRUE gtk.timeout_add(500, timeout) gtk.mainloop()
def __init__(self, echoer): l.hide() self.echoer = echoer w = gtk.GtkWindow(gtk.WINDOW_TOPLEVEL) vb = gtk.GtkVBox(); b = gtk.GtkButton("Echo:") self.entry = gtk.GtkEntry(); self.outry = gtk.GtkEntry() w.add(vb) map(vb.add, [b, self.entry, self.outry]) b.connect('clicked', self.clicked) w.connect('destroy', gtk.mainquit) w.show_all()
def __init__(self): self.canvas = None self.window = gtk.GtkWindow(gtk.WINDOW_TOPLEVEL) self.window.connect("delete_event", self.delete_event) self.window.set_title("jXPMap Editor") self.box0 = gtk.GtkVBox(gtk.FALSE, 0) menubar = self.buildMenuBar() self.box0.pack_start(menubar, gtk.FALSE, gtk.FALSE, 0) self.box1 = gtk.GtkHBox(gtk.FALSE, 0) self.box0.pack_start(self.box1, gtk.TRUE, gtk.TRUE, 0) self.window.add(self.box0) self.buildToolBar() #self.ActionMap() #self.buildInputMap() # The visual calls are needed to make sure drawing bitmaps # (draw_*_image) works # ... at least according to some documentation that doesn't look # entirely reliable gtk.push_rgb_visual() area = gtk.GtkDrawingArea() gtk.pop_visual() area.size(500, 500) self.box1.pack_start(area, gtk.TRUE, gtk.TRUE, 0) area.connect("expose-event", self.area_expose_cb) # Change the default background to black so that the window # doesn't flash badly when resizing style = area.get_style().copy() style.bg[gtk.STATE_NORMAL] = area.get_colormap().alloc(0, 0, 0) area.set_style(style) area.connect("button_press_event", self.mouse_event) area.connect("button_release_event", self.mouse_event) area.connect("motion_notify_event", self.mouse_event) area.connect("configure_event", self.configure_event) area.set_events(GDK.EXPOSURE_MASK | GDK.BUTTON_PRESS_MASK | GDK.BUTTON_RELEASE_MASK | GDK.POINTER_MOTION_MASK | GDK.POINTER_MOTION_HINT_MASK) # The HINT_MASK means there won't be a callback for every mouse # motion event, only after certain other events or after an explicit # reading of the location with x, y = window.pointer. # This helps to avoid getting a queue of events if they're not handled # quickly enough. area.show() self.zoom = 0 self.box1.show() self.box0.show() self.window.show() self.canvas = MapCanvas(area)
def main(): from vtkmodules.vtkFiltersSources import vtkConeSource from vtkmodules.vtkRenderingCore import vtkActor, vtkPolyDataMapper, vtkRenderer # load implementations for rendering and interaction factory classes import vtkmodules.vtkRenderingOpenGL2 import vtkmodules.vtkInteractionStyle # The main window window = gtk.GtkWindow(gtk.WINDOW_TOPLEVEL) window.set_title("A GtkVTKRenderWindow Demo!") window.connect("destroy", gtk.mainquit) window.connect("delete_event", gtk.mainquit) window.set_border_width(10) # A VBox into which widgets are packed. vbox = gtk.GtkVBox(spacing=3) window.add(vbox) vbox.show() # The GtkVTKRenderWindow gvtk = GtkVTKRenderWindowInteractor() #gvtk.SetDesiredUpdateRate(1000) gvtk.set_usize(400, 400) vbox.pack_start(gvtk) gvtk.show() gvtk.Initialize() gvtk.Start() # prevents 'q' from exiting the app. gvtk.AddObserver("ExitEvent", lambda o, e, x=None: x) # The VTK stuff. cone = vtkConeSource() cone.SetResolution(80) coneMapper = vtkPolyDataMapper() coneMapper.SetInputConnection(cone.GetOutputPort()) #coneActor = vtkLODActor() coneActor = vtkActor() coneActor.SetMapper(coneMapper) coneActor.GetProperty().SetColor(0.5, 0.5, 1.0) ren = vtkRenderer() gvtk.GetRenderWindow().AddRenderer(ren) ren.AddActor(coneActor) # A simple quit button quit = gtk.GtkButton("Quit!") quit.connect("clicked", gtk.mainquit) vbox.pack_start(quit) quit.show() # show the main window and start event processing. window.show() gtk.mainloop()
def __init__(self, size=(500, 400), name="p4VASP graph", infoline=None, drawing_area=None, top=None, world=None, graphdata=None): self.lastmotiontime = 0 width, height = (int(round(size[0])), int(round(size[1]))) self.world = world if drawing_area is None: if top is None: top = gtk.GtkWindow() vbox = gtk.GtkVBox() da = gtk.GtkDrawingArea() top.add(vbox) vbox.pack_start(da) if infoline: sbar = self.__sbar = gtk.GtkStatusbar() vbox.pack_end(sbar, expand=0) sbar.set_border_width(2) else: self.__sbar = None else: da = drawing_area if infoline is None: self.__sbar = None else: self.__sbar = infoline self.top = top piddleGTKp4.InteractiveCanvas.__init__(self, da, top) # top.set_wmclass("canvas", "Canvas") da.realize() da.set_usize(width, height) # top.show_all() # top.set_icon_name(name) # top.set_title(name) self.ensure_size(width, height) self.__status = None self.world = world self.graphdata = graphdata self.onOver = self.onOverCallback self.onClick = self.onClickCallback self.onKey = self.onKeyCallback self.point = -1, -1 self.selected_begin = None
def functions_help_window(*args): if gui["fhelp_window"] == 0: win = gtk.GtkWindow() gui["fhelp_window"] = win win.set_policy(gtk.TRUE, gtk.TRUE, gtk.FALSE) win.set_title("Available functions and constants") win.set_usize(500, 300) win.connect("delete_event", fhelp_window_close) win.set_border_width(4) window_pos_mode(win) vbox = gtk.GtkVBox(spacing=5) win.add(vbox) vbox.show() scrolled_window = gtk.GtkScrolledWindow() vbox.pack_start(scrolled_window, expand=gtk.TRUE) scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled_window.show() clist = gtk.GtkCList(2) clist.set_row_height(18) clist.set_column_width(0, 180) clist.set_column_width(1, 520) clist.set_selection_mode(gtk.SELECTION_BROWSE) set_font(clist) scrolled_window.add(clist) clist.show() mlist = map(lambda i: "", range(2)) clist.freeze() for i in range(len(flist) / 2): mlist[0] = flist[i * 2] mlist[1] = flist[i * 2 + 1] clist.append(mlist) clist.thaw() button = gtk.GtkButton("Close") button.connect("clicked", fhelp_window_close) vbox.pack_start(button, expand=gtk.FALSE) button.set_flags(gtk.CAN_DEFAULT) button.grab_default() button.show() gui["fhelp_window"].show() else: gui["fhelp_window"].get_window()._raise()
def __init__(self): pywidgets.Interaction.__init__(self) self.signal_connect('destroy', gtk.mainquit, None) if _GNOME_POWER: self.display = BrowserDisplay() dWindow = gtk.GtkWindow(title="Spelunking") dWindow.add(self.display) dWindow.show_all() self.display.makeDefaultCanvas() else: self.display = BrowserDisplay(self) # The referencable attached to the Perspective self.client = self
def mk_wnd(self, title): wnd = gtk.GtkWindow() wnd.set_title(title) self.box = gtk.GtkVBox() self.textbox = gtk.GtkHBox() e = gtk.GtkEntry() self.textentry = e e.show() self.textbox.pack_start(e) b = gtk.GtkButton('Lookup') def looker(button): self.lookup('', e.get_text()) b.connect('released', looker) b.show() self.textbox.pack_start(b) self.textbox.show() self.box.pack_start(self.textbox) def mk_sel_changed(fn): def sel_changed(l, fn=fn): sel = l.get_selection() if len(sel) > 0: s = sel[0].children()[0].get() (typ, val) = split_tv(s) fn(typ, val) return sel_changed def make_lb(text, fn, box): lb = gtk.GtkList() lb.show() frame = gtk.GtkFrame(text) frame.add(lb) frame.show() box.pack_start(frame) lb.connect('selection-changed', fn) return lb self.lb_head = make_lb('Head terms', mk_sel_changed(self.set_head), self.box) self.lb_rel = make_lb('Relations', mk_sel_changed(self.lookup), self.box) self.box.show() wnd.add(self.box) wnd.show() return wnd
def __init__(self, title, text): self.window = gtk.GtkWindow(gtk.WINDOW_POPUP) self.window.set_title(title) self.window.set_position(gtk.WIN_POS_CENTER) self.window.set_modal(gtk.TRUE) self.label = gtk.GtkLabel(text) self.label.set_line_wrap(gtk.TRUE) box = gtk.GtkFrame() box.set_border_width(8) box.add(self.label) box.set_shadow_type(gtk.SHADOW_NONE) frame = gtk.GtkFrame() frame.set_shadow_type(gtk.SHADOW_OUT) frame.add(box) self.window.add(frame) self.window.show_all()
def main(): top = gtk.GtkWindow() bbox = gtk.GtkVButtonBox() bbox.set_spacing(0) top.add(bbox) top.connect("destroy", gtk.mainquit) top.connect("delete_event", gtk.mainquit) tests = map((lambda test: (string.capitalize(test.__name__), test)), piddletest.tests) tests.extend(testitems) for name, test in tests: b = gtk.GtkButton(name) b.connect("clicked", Test(test)) bbox.pack_start(b) top.show_all() gtk.mainloop()
def about_window(): win = gtk.GtkWindow() gui["about_window"] = win win.set_policy(gtk.TRUE, gtk.TRUE, gtk.FALSE) win.set_title("About") win.connect("delete_event", about_window_close) win.set_border_width(2) window_pos_mode(win) frame = gtk.GtkFrame() frame.show() frame.set_border_width(2) win.add(frame) vbox = gtk.GtkVBox(spacing=5) vbox.show() frame.add(vbox) label = gtk.GtkLabel("\n\n" + "Clarence (programmer's calculator)\n" "\nversion " + version + "\n\n" "Written by Tomasz Maka <*****@*****.**>\n") set_font(label) label.show() vbox.pack_start(label) entry = gtk.GtkEntry() gui["http_entry"] = entry entry.set_editable(gtk.FALSE) entry.set_usize(290, -2) set_font(entry) entry.show() vbox.pack_start(entry) entry.set_text("http://clay.ll.pl/clarence.html") button = gtk.GtkButton("OK") button.connect("clicked", about_window_close) vbox.pack_start(button, expand=gtk.FALSE) button.set_flags(gtk.CAN_DEFAULT) button.grab_default() button.show() gui["main_window"].set_sensitive(gtk.FALSE) gui["about_window"].show()
def main(): window = gtk.GtkWindow(gtk.WINDOW_TOPLEVEL) window.set_name ("Test Input") vbox = gtk.GtkVBox(gtk.FALSE, 0) window.add(vbox) vbox.show() window.connect("destroy", gtk.mainquit) # Create the drawing area drawing_area = gtk.GtkDrawingArea() drawing_area.size(200, 200) vbox.pack_start(drawing_area, gtk.TRUE, gtk.TRUE, 0) drawing_area.show() # Signals used to handle backing pixmap drawing_area.connect("expose_event", expose_event) drawing_area.connect("configure_event", configure_event) # Event signals drawing_area.connect("motion_notify_event", motion_notify_event) drawing_area.connect("button_press_event", button_press_event) drawing_area.set_events(GDK.EXPOSURE_MASK | GDK.LEAVE_NOTIFY_MASK | GDK.BUTTON_PRESS_MASK | GDK.POINTER_MOTION_MASK | GDK.POINTER_MOTION_HINT_MASK) # .. And a quit button button = gtk.GtkButton("Quit") vbox.pack_start(button, gtk.FALSE, gtk.FALSE, 0) button.connect_object("clicked", window.destroy, window) button.show() window.show() gtk.mainloop() return 0
def main(): # The main window window = gtk.GtkWindow(gtk.WINDOW_TOPLEVEL) window.set_title("A GtkVTKRenderWindow Demo!") window.connect("destroy", gtk.mainquit) window.connect("delete_event", gtk.mainquit) window.set_border_width(10) # A VBox into which widgets are packed. vbox = gtk.GtkVBox(spacing=3) window.add(vbox) vbox.show() # The GtkVTKRenderWindow gvtk = GtkVTKRenderWindow() #gvtk.SetDesiredUpdateRate(1000) gvtk.set_usize(400, 400) vbox.pack_start(gvtk) gvtk.show() # The VTK stuff. cone = vtk.vtkConeSource() cone.SetResolution(80) coneMapper = vtk.vtkPolyDataMapper() coneMapper.SetInputConnection(cone.GetOutputPort()) #coneActor = vtk.vtkLODActor() coneActor = vtk.vtkActor() coneActor.SetMapper(coneMapper) coneActor.GetProperty().SetColor(0.5, 0.5, 1.0) ren = vtk.vtkRenderer() gvtk.GetRenderWindow().AddRenderer(ren) ren.AddActor(coneActor) # A simple quit button quit = gtk.GtkButton("Quit!") quit.connect("clicked", gtk.mainquit) vbox.pack_start(quit) quit.show() # show the main window and start event processing. window.show() gtk.mainloop()
def __init__(self): ## create gtk window self.window = gtk.GtkWindow(gtk.WINDOW_TOPLEVEL) self.window.connect("destroy", self.destroy) self.window.set_border_width(10) self.window.set_usize(140, 100) self.control_box = gtk.GtkVBox(gtk.FALSE, 0) self.window.add(self.control_box) self.control_box.show() ## create startbutton self.startbutton = gtk.GtkButton("perform test") self.startbutton.connect("clicked", self.apply_function, self.control_box) self.control_box.add(self.startbutton) self.startbutton.show() ## create quitbutton self.quitbutton = gtk.GtkButton("Quit") self.quitbutton.connect("clicked", self.destroy) self.control_box.add(self.quitbutton) self.quitbutton.show()
def main(): global glarea, timer_id win = gtk.GtkWindow() win.set_title("GL Dots") win.connect("destroy", gtk.mainquit) glarea = gtkgl.GtkGLArea((gtkgl.RGBA, gtkgl.DOUBLEBUFFER)) glarea.add_events(gtk.GDK.BUTTON_PRESS_MASK) glarea.size(300, 300) setup_viewport() glarea.connect_after("size_allocate", reshape) glarea.connect("expose_event", display) glarea.connect("button_press_event", mouse) timer_id = gtk.idle_add(display) win.add(glarea) glarea.show() win.show() gtk.mainloop() glarea.destroy()
def __init__(self): itemnames = ["Foo", "Bar", "Baz", "Quux", "Maurice"] # a generic toplevel window window = gtk.GtkWindow(gtk.WINDOW_TOPLEVEL) window.connect("delete_event", gtk.mainquit) window.set_border_width(5) # A generic scrolled window scrolled_win = gtk.GtkScrolledWindow() scrolled_win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled_win.set_usize(150, 200) window.add(scrolled_win) scrolled_win.show() # Create the root tree tree = gtk.GtkTree() print "root tree is %s" % tree # connect all GtkTree:: signals tree.connect("select_child", self.cb_select_child, tree) tree.connect("unselect_child", self.cb_unselect_child, tree) tree.connect("selection_changed", self.cb_selection_changed) # Add it to the scrolled window scrolled_win.add_with_viewport(tree) # Set the selection mode tree.set_selection_mode(gtk.SELECTION_MULTIPLE) # Show it tree.show() for i in range(5): # Create a tree item item = gtk.GtkTreeItem(itemnames[i]) # Connect all GtkItem:: and GtkTreeItem:: signals item.connect("select", self.cb_itemsignal, "select") item.connect("deselect", self.cb_itemsignal, "deselect") item.connect("toggle", self.cb_itemsignal, "toggle") item.connect("expand", self.cb_itemsignal, "expand") item.connect("collapse", self.cb_itemsignal, "collapse") # Add it to the parent tree tree.append(item) # Show it - this can be done at any time item.show() # Create this item's subtree subtree = gtk.GtkTree() print "-> item %s->%s, subtree %s" % (itemnames[i], item, subtree) # This is still necessary if you want these signals to be called # for the subtree's children. Note that selection_change will be # signalled for the root tree regardless. subtree.connect("select_child", self.cb_select_child, subtree) subtree.connect("unselect_child", self.cb_unselect_child, subtree) # This has absolutely no effect, because it is completely ignored # in subtrees subtree.set_selection_mode(gtk.SELECTION_SINGLE) # Neither does this, but for a rather different reason - the # view_mode and view_line values of a tree are propagated to # subtrees when they are mapped. So, setting it later on would # actually have a (somewhat unpredictable) effect subtree.set_view_mode(gtk.TREE_VIEW_ITEM) # Set this item's subtree - note that you cannot do this until # AFTER the item has been added to its parent tree! item.set_subtree(subtree) for j in range(5): # Create a subtree item, in much the same way subitem = gtk.GtkTreeItem(itemnames[j]) # Connect all GtkItem:: and GtkTreeItem:: signals subitem.connect("select", self.cb_itemsignal, "select") subitem.connect("deselect", self.cb_itemsignal, "deselect") subitem.connect("toggle", self.cb_itemsignal, "toggle") subitem.connect("expand", self.cb_itemsignal, "expand") subitem.connect("collapse", self.cb_itemsignal, "collapse") print "-> -> item %s->%s\n" % (itemnames[j], subitem) # Add it to its parent tree subtree.append(subitem) # Show it subitem.show() # Show the window and loop endlessly window.show()
def __init__(self): titles = ["Ingredients", "Amount"] self.flag = 0 window = gtk.GtkWindow(gtk.WINDOW_TOPLEVEL) window.set_usize(300, 150) window.set_title("GtkCList Example") window.connect("destroy", gtk.mainquit) vbox = gtk.GtkVBox(gtk.FALSE, 5) vbox.set_border_width(5) window.add(vbox) vbox.show() # Create a scrolled window to pack the CList widget into scrolled_window = gtk.GtkScrolledWindow() scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS) vbox.pack_start(scrolled_window, gtk.TRUE, gtk.TRUE, 0) scrolled_window.show() # Create the CList. For this example we use 2 columns clist = gtk.GtkCList(2, titles) # When a selection is made, we want to know about it. The callback # used is selection_made, and its code can be found further down clist.connect("select_row", self.selection_made) # It isn't necessary to shadow the border, but it looks nice :) clist.set_shadow_type(gtk.SHADOW_OUT) # What however is important, is that we set the column widths as # they will never be right otherwise. Note that the columns are # numbered from 0 and up (to 1 in this case). clist.set_column_width(0, 150) # Add the CList widget to the vertical box and show it. scrolled_window.add(clist) clist.show() # Create the buttons and add them to the window. See the button # tutorial for more examples and comments on this. hbox = gtk.GtkHBox(gtk.FALSE, 0) vbox.pack_start(hbox, gtk.FALSE, gtk.TRUE, 0) hbox.show() button_add = gtk.GtkButton("Add List") button_clear = gtk.GtkButton("Clear List") button_hide_show = gtk.GtkButton("Hide/Show titles") hbox.pack_start(button_add, gtk.TRUE, gtk.TRUE, 0) hbox.pack_start(button_clear, gtk.TRUE, gtk.TRUE, 0) hbox.pack_start(button_hide_show, gtk.TRUE, gtk.TRUE, 0) # Connect our callbacks to the three buttons button_add.connect_object("clicked", self.button_add_clicked, clist) button_clear.connect_object("clicked", self.button_clear_clicked, clist) button_hide_show.connect_object("clicked", self.button_hide_show_clicked, clist) button_add.show() button_clear.show() button_hide_show.show() # The interface is completely set up so we show the window and # enter the gtk_main loop. window.show()
time.sleep(5./num_cycles) self.widget.set_text("No threads running") def start_new_thread (button, widget, bar, data=None): global threadcount threadcount += 1 a = Worker(widget,bar, threadcount) a.start() def destroy(*args): window.hide() gtk.mainquit() window = gtk.GtkWindow(gtk.WINDOW_TOPLEVEL) window.connect("destroy", destroy) window.set_border_width(10) window.set_usize(500, 100) control_box = gtk.GtkVBox(gtk.FALSE,0) window.add(control_box) control_box.show() ## create label label = gtk.GtkLabel() control_box.add(label) label.set_text("No threads running") label.show() ## create static bar
def init_dialog(self): self.dialog = gtk.GtkWindow() self.dialog.set_title('GDAL Export Tool') self.dialog.set_border_width(10) self.tips = gtk.GtkTooltips() #self.dialog.set_default_size(500,400) self.dialog.set_policy(gtk.FALSE, gtk.TRUE, gtk.TRUE) # main shell mainshell = gtk.GtkHBox(spacing=1, homogeneous=gtk.FALSE) self.dialog.add(mainshell) self.show_list = [] self.adv_show_list = [] # advanced show list self.show_list.append(mainshell) #navigation shell navshell = gtk.GtkVBox(spacing=1, homogeneous=gtk.FALSE) mainshell.pack_start(navshell) self.show_list.append(navshell) self.frame_dict = {} self.button_dict = {} self.frame_dict['Files'] = gvutils.GvDataFilesFrame( 'Data Files', sel_list=('Input', 'Output')) self.frame_dict['Files'].set_border_width(5) self.frame_dict['Files'].set_spacings(5, 5) self.frame_dict['Files'].show_all() navshell.pack_start(self.frame_dict['Files']) self.show_list.append(self.frame_dict['Files']) bopt_frame = gtk.GtkFrame('Basic Options') self.frame_dict['Basic Options'] = bopt_frame self.show_list.append(bopt_frame) navshell.pack_start(bopt_frame, gtk.FALSE, gtk.FALSE, 0) bopt_table = gtk.GtkTable(2, 4, gtk.FALSE) bopt_table.set_border_width(5) bopt_table.set_row_spacings(5) bopt_table.set_col_spacings(5) bopt_frame.add(bopt_table) self.show_list.append(bopt_table) # Might be nice to have more formats below, but # this involves error checking to test for # supported data types, etc. fmtlabel = gtk.GtkLabel('Output Format: ') fmtlabel.set_alignment(0, 0.5) self.show_list.append(fmtlabel) bopt_table.attach(fmtlabel, 0, 1, 0, 1) self.format_list = [] hist_idx = 0 for iDriver in gdal.GetDriverList(): create = None try: create = iDriver.GetMetadata()["DCAP_CREATE"] except KeyError: try: create = iDriver.GetMetadata()["DCAP_CREATECOPY"] except KeyError: pass if create == "YES": if iDriver.ShortName == 'DTED': # DTED is a special case that needs certain # conditions to be valid. Skip it. continue self.format_list.append(iDriver.ShortName) self.format_list.sort() # Default to GTiff if possible try: hist_idx = self.format_list.index('GTiff') except ValueError: pass self.format_menu = gvutils.GvOptionMenu(self.format_list) self.format_menu.set_history(hist_idx) self.show_list.append(self.format_menu) bopt_table.attach(self.format_menu, 1, 2, 0, 1) self.button_dict['Format_help'] = gtk.GtkButton('Help') self.show_list.append(self.button_dict['Format_help']) bopt_table.attach(self.button_dict['Format_help'], 2, 3, 0, 1) reslabel = gtk.GtkLabel('Output Resolution: ') reslabel.set_alignment(0, 0.5) self.show_list.append(reslabel) bopt_table.attach(reslabel, 0, 1, 1, 2) self.res_list = ['Full', '1:2', '1:4', '1:8'] self.res_menu = gvutils.GvOptionMenu(self.res_list) bopt_table.attach(self.res_menu, 1, 2, 1, 2) self.show_list.append(self.res_menu) self.button_dict['Mode'] = gtk.GtkCheckButton('Advanced Options') navshell.pack_start(self.button_dict['Mode']) self.show_list.append(self.button_dict['Mode']) self.frame_dict['IP_window'] = DataWindowFrame(navshell) self.adv_show_list.append(self.frame_dict['IP_window']) iopt_frame = gtk.GtkFrame('Interactive Options') self.frame_dict['Interactive Options'] = iopt_frame self.adv_show_list.append(iopt_frame) navshell.pack_start(iopt_frame, gtk.FALSE, gtk.FALSE, 0) iopt_table = gtk.GtkTable(3, 3, gtk.FALSE) iopt_table.set_border_width(5) iopt_table.set_row_spacings(5) iopt_table.set_col_spacings(5) iopt_frame.add(iopt_table) self.adv_show_list.append(iopt_table) self.button_dict['IP_window'] = gtk.GtkCheckButton('Window Input File') iopt_table.attach(self.button_dict['IP_window'], 0, 2, 0, 1) self.adv_show_list.append(self.button_dict['IP_window']) self.button_dict['Scale'] = gtk.GtkCheckButton( 'Scale to View Settings') self.tips.set_tip( self.button_dict['Scale'], 'Scale the output bands ' + 'according to the min/max settings of the ' + 'currently active raster layer. This only ' + 'applies to real data.') iopt_table.attach(self.button_dict['Scale'], 0, 2, 1, 2) self.adv_show_list.append(self.button_dict['Scale']) self.button_dict['Refresh'] = gtk.GtkButton( 'Active Layer->Input Filename') self.tips.set_tip( self.button_dict['Refresh'], 'Set the input ' + 'filename to that of the currently active layer') iopt_table.attach(self.button_dict['Refresh'], 0, 1, 2, 3) self.adv_show_list.append(self.button_dict['Refresh']) self.button_dict['Enable_ROI'] = gtk.GtkButton('Draw ROI mode') self.tips.set_tip( self.button_dict['Enable_ROI'], 'Re-activate the ' + 'ROI mode used for interactive input file window definition') iopt_table.attach(self.button_dict['Enable_ROI'], 1, 2, 2, 3) self.adv_show_list.append(self.button_dict['Enable_ROI']) self.frame_dict['Other_Advanced'] = gtk.GtkFrame('') self.frame_dict['Other_Advanced'].set_shadow_type(gtk.SHADOW_NONE) self.adv_show_list.append(self.frame_dict['Other_Advanced']) oadvbox = gtk.GtkVBox(spacing=5, homogeneous=gtk.FALSE) oadvbox.set_border_width(5) self.adv_show_list.append(oadvbox) self.frame_dict['Other_Advanced'].add(oadvbox) otable = gtk.GtkTable(2, 3, gtk.FALSE) otable.set_row_spacings(5) otable.set_col_spacings(5) self.adv_show_list.append(otable) oadvbox.pack_start(otable) self._overview_list = ['None', 'Nearest', 'Average'] self.overview_menu = gvutils.GvOptionMenu(self._overview_list) ovrlabel = gtk.GtkLabel('Overviews:') self.tips.set_tip(self.overview_menu, 'Tiled overview creation options') ovrlabel.set_alignment(0, 0.5) self.adv_show_list.append(ovrlabel) otable.attach(ovrlabel, 0, 1, 0, 1) otable.attach(self.overview_menu, 1, 2, 0, 1) self.adv_show_list.append(self.overview_menu) self._geocode_list = ['Default', 'GCP', 'Geotransform'] self.geocoding_menu = gvutils.GvOptionMenu(self._geocode_list) geolabel = gtk.GtkLabel('Geocoding:') self.tips.set_tip( self.geocoding_menu, 'Specify the type of georeferencing ' + 'information to output. Default is to output ' + 'all available geocoding from the input file. ' + 'If GCP or Geotransform is selected, geocoding ' + 'information will only be output if it is of the ' + 'selected type. This may later be updated to ' + 'generate information of the specified form if ' + 'it is not present but can be accurately computed ' + 'from the existing information.') geolabel.set_alignment(0, 0.5) self.adv_show_list.append(geolabel) otable.attach(geolabel, 0, 1, 1, 2) otable.attach(self.geocoding_menu, 1, 2, 1, 2) self.adv_show_list.append(self.geocoding_menu) opthbox = gtk.GtkHBox(spacing=5, homogeneous=gtk.FALSE) self.adv_show_list.append(opthbox) oadvbox.pack_start(opthbox) optlabel = gtk.GtkLabel('Create Options:') optlabel.set_alignment(0, 0.5) self.adv_show_list.append(optlabel) self.optentry = gtk.GtkEntry() self.optentry.set_editable(editable=gtk.TRUE) self.optentry.set_usize(400, 25) self.optentry.set_text('') self.adv_show_list.append(self.optentry) opthbox.pack_start(optlabel) opthbox.pack_start(self.optentry) navshell.pack_start(self.frame_dict['Other_Advanced'], gtk.FALSE, gtk.FALSE, 0) echbox = gtk.GtkHBox(spacing=5, homogeneous=gtk.FALSE) echbox.set_border_width(3) navshell.pack_end(echbox, gtk.FALSE, gtk.FALSE, 0) self.show_list.append(echbox) self.button_dict['Close'] = gtk.GtkButton('Close') echbox.pack_end(self.button_dict['Close'], expand=gtk.TRUE) self.show_list.append(self.button_dict['Close']) self.button_dict['Export'] = gtk.GtkButton('Export') echbox.pack_end(self.button_dict['Export'], expand=gtk.TRUE) self.show_list.append(self.button_dict['Export']) self.button_dict['Format_help'].connect('clicked', self.format_help_cb) self.button_dict['Enable_ROI'].connect('clicked', self.set_roitool) self.button_dict['Refresh'].connect('clicked', self.refresh_fileinfo) self.button_dict['Export'].connect('clicked', self.export_cb) self.button_dict['Close'].connect('clicked', self.close) self.button_dict['IP_window'].connect('toggled', self.ip_window_toggled_cb) self.button_dict['Mode'].connect('toggled', self.mode_toggled_cb) self.button_dict['IP_window'].set_active(gtk.FALSE) self.button_dict['Mode'].set_active(gtk.FALSE) self.frame_dict['IP_window'].set_entry_sensitivities(gtk.FALSE) # Trap window close event self.dialog.connect('delete-event', self.close) for item in self.show_list: item.show() if self.button_dict['Mode'].get_active(): for item in self.adv_show_list: item.show() else: for item in self.adv_show_list: item.hide()
def showgui_cb(self, *args): if self.dialog is None: self.dialog = gtk.GtkWindow() self.dialog.connect('delete-event', self.close) table = gtk.GtkTable(9, 4) table.set_border_width(10) table.set_row_spacings(10) table.set_col_spacings(10) vbox = gtk.GtkVBox() self.dialog.add(vbox) vbox.pack_start(table) iconbar = gtk.GtkToolbar(gtk.ORIENTATION_HORIZONTAL, gtk.TOOLBAR_ICONS) arrows = [] atypes = [ gtk.ARROW_LEFT, gtk.ARROW_UP, gtk.ARROW_DOWN, gtk.ARROW_RIGHT ] cbs = [ self.rewind_cb, self.speed_up_cb, self.speed_down_cb, self.play_cb ] for atype, cb in map(None, atypes, cbs): arr = gtk.GtkButton() arr.set_border_width(0) arr.set_relief(gtk.RELIEF_NONE) arr.add(gtk.GtkArrow(atype)) arr.connect('clicked', cb) arrows.append(arr) vbox = gtk.GtkVBox(spacing=0, homogeneous=gtk.FALSE) vbox.pack_start(arrows[1], expand=gtk.FALSE) vbox.pack_start(arrows[2], expand=gtk.FALSE) # Now put them in the toolbar iconbar.append_widget(arrows[0], 'Rewind', 'Rewind') iconbar.append_widget(vbox, 'Adjust speed', 'Adjust speed') iconbar.append_widget(arrows[3], 'Play', 'Play') table.attach(iconbar, 0, 1, 0, 1) but = gtk.GtkButton('Stop') table.attach(but, 1, 2, 0, 1) but.connect('clicked', self.stop_pan_cb) but = gtk.GtkButton('Pause') table.attach(but, 2, 3, 0, 1) but.connect('clicked', self.pause_pan_cb) label = gtk.GtkLabel('Block Size Mode:') label.set_alignment(0, 0.5) table.attach(label, 0, 1, 1, 2) self.block_size_menu = gvutils.GvOptionMenu( ('Relative to Pan Extents', 'View Coordinates', 'Constant Resolution'), self.block_mode_changed) table.attach(self.block_size_menu, 1, 3, 1, 2) self.block_label_list = [ 'Block x size (0-1):', 'Block x size:', 'View units/Pixel:' ] self.block_label = gtk.GtkLabel(self.block_label_list[0]) self.block_label.set_alignment(0, 0.5) table.attach(self.block_label, 0, 1, 2, 3) self.block_entry = gtk.GtkEntry() self.block_entry.set_editable(gtk.TRUE) self.block_entry.set_text('0.125') self.block_entry.connect('leave-notify-event', self.block_size_changed) table.attach(self.block_entry, 1, 3, 2, 3) label = gtk.GtkLabel('Overlap (0-1):') label.set_alignment(0, 0.5) table.attach(label, 0, 1, 3, 4) self.overlap_entry = gtk.GtkEntry() self.overlap_entry.set_editable(gtk.TRUE) self.overlap_entry.set_text('0.1') self.overlap_entry.connect('leave-notify-event', self.overlap_changed) table.attach(self.overlap_entry, 1, 3, 3, 4) label = gtk.GtkLabel('Path type:') label.set_alignment(0, 0.5) table.attach(label, 0, 1, 4, 5) self.path_menu = gvutils.GvOptionMenu(('0', '1', '2', '3', '4'), self.path_changed) table.attach(self.path_menu, 1, 3, 4, 5) label = gtk.GtkLabel('Show trail:') label.set_alignment(0, 0.5) table.attach(label, 0, 1, 5, 6) self.trail_menu = gvutils.GvOptionMenu(('No', 'Yes'), self.trail_changed) table.attach(self.trail_menu, 1, 2, 5, 6) button = gtk.GtkButton('Clear Trail') table.attach(button, 2, 3, 5, 6) button.connect('clicked', self.clear_trail) label = gtk.GtkLabel('Trail Color:') label.set_alignment(0, 0.5) table.attach(label, 0, 1, 6, 7) self.trail_color = pgucolorsel.ColorControl( 'Trail Color', self.trail_color_cb) table.attach(self.trail_color, 1, 3, 6, 7) self.trail_color.set_color((1.0, 0.75, 0.0, 0.5)) self.second_view = gview.GvViewArea() self.second_view.set_usize(300, 300) table.attach(self.second_view, 0, 3, 7, 8) self.dialog.show_all() self.dialog.connect('delete-event', self.close) self.viewtitle = args[1] self.dialog.show() self.dialog.get_window()._raise()
def __init__(self): # Create a window to put all the widgets in # connect main_quit() to the "destroy" event of # the window to handle window manager close-window-events window = gtk.GtkWindow(gtk.WINDOW_TOPLEVEL) window.set_title("GtkList Example") window.connect("destroy", gtk.mainquit) # Inside the window we need a box to arrange the widgets # vertically vbox = gtk.GtkVBox(gtk.FALSE, 5) vbox.set_border_width(5) window.add(vbox) vbox.show() # This is the scrolled window to put the List widget inside scrolled_window = gtk.GtkScrolledWindow() scrolled_window.set_usize(250, 150) vbox.add(scrolled_window) scrolled_window.show() # Create the GtkList widget. # Connect the sigh_print_selection() signal handler # function to the "selection_changed" signal of the List # to print out the selected items each time the selection # has changed gtklist = gtk.GtkList() scrolled_window.add_with_viewport(gtklist) gtklist.show() gtklist.connect("selection_changed", self.sigh_print_selection) # We create a "Prison" to put a list item in ) frame = gtk.GtkFrame("Prison") frame.set_usize(200, 50) frame.set_border_width(5) frame.set_shadow_type(gtk.SHADOW_OUT) vbox.add(frame) frame.show() # Connect the sigh_button_event() signal handler to the List # which will handle the "arresting" of list items gtklist.connect("button_release_event", self.sigh_button_event, frame) # Create a separator separator = gtk.GtkHSeparator() vbox.add(separator) separator.show() # Finally create a button and connect its "clicked" signal # to the destruction of the window button = gtk.GtkButton("Close") vbox.add(button) button.show() button.connect_object("clicked", window.destroy, window) # Now we create 5 list items, each having its own # label and add them to the List using add() # Also we query the text string from the label and # associate it with the list_item_data_key for each list item for i in range(5): buffer = "ListItemContainer with Label #%d" % i label = gtk.GtkLabel(buffer) list_item = gtk.GtkListItem() list_item.add(label) label.show() gtklist.add(list_item) list_item.show() string = label.get() list_item.set_data(self.list_item_data_key, string) # Here, we are creating another 5 labels, this time # we use GtkListItem() for the creation # For adding of the list items we put them all into a # list, and then add them by a single call to # append_items(). dlist = [] for i in range(5, 10): buffer = "List Item with Label %d" % i list_item = gtk.GtkListItem(buffer) dlist.append(list_item) list_item.show() list_item.set_data(self.list_item_data_key, list_item.children()[0].get()) gtklist.append_items(dlist) # Finally we want to see the window, don't we? ) window.show()
glEndList() gear3 = glGenLists(1) glNewList(gear3, GL_COMPILE) glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue ) gear( 1.3, 2.0, 0.5, 10, 0.7 ) glEndList() glEnable( GL_NORMALIZE ) if not gtkgl.query(): print "OpenGL not supported. Bye." raise SystemExit win = gtk.GtkWindow() win.connect("destroy", gtk.mainquit) win.set_title("Gears") table = gtk.GtkTable(4, 2) win.add(table) table.show() glarea = gtkgl.GtkGLArea((gtkgl.RGBA, gtkgl.DEPTH_SIZE, 1, gtkgl.DOUBLEBUFFER)) glarea.size(300, 300) glarea.connect("realize", init) glarea.connect("size_allocate", reshape) glarea.connect("expose_event", draw) gtk.idle_add(idle)
def create_main_window(*args): win = gtk.GtkWindow() gui["main_window"] = win win.set_policy(gtk.TRUE, gtk.TRUE, gtk.FALSE) win.set_title("Clarence " + version) win.set_usize(hive.get_integer("/window/width", default_win_width), hive.get_integer("/window/height", default_win_height)) win.connect("delete_event", gtk.mainquit) window_pos_mode(win) vbox1 = gtk.GtkVBox(spacing=5) win.add(vbox1) vbox1.show() ag = gtk.GtkAccelGroup() itemf = gtk.GtkItemFactory(gtk.GtkMenuBar, "<main>", ag) gui["main_window"].add_accel_group(ag) itemf.create_items([ ('/_Misc', None, None, 0, '<Branch>'), ('/_Misc/_Clear', 'Escape', main_menu, 1, ''), ('/_Misc/sep1', None, None, 0, '<Separator>'), ('/_Misc/Pre_ferences', '<control>P', main_menu, 3, ''), ('/_Misc/sep1', None, None, 0, '<Separator>'), ('/_Misc/E_xit', '<alt>X', main_menu, 2, ''), ('/_Insert', None, None, 0, '<Branch>'), ('/_Insert/_Bin value', '<control>comma', insert_menu, 1, ''), ('/_Insert/_ASCII chars', '<control>period', insert_menu, 2, ''), ('/_Insert/_Last result', '<control>slash', insert_menu, 3, ''), ('/_Select', None, None, 0, '<Branch>'), ('/_Select/_Decimal field', '<control>1', select_menu, 1, ''), ('/_Select/_Hexadecimal field', '<control>2', select_menu, 2, ''), ('/_Select/_Octal field', '<control>3', select_menu, 3, ''), ('/_Select/_ASCII field', '<control>4', select_menu, 4, ''), ('/_Select/_Binary field', '<control>5', select_menu, 5, ''), ('/_Select/sep1', None, None, 0, '<Separator>'), ('/_Select/_Clear fields', '<control>0', select_menu, 6, ''), ('/_Help', None, None, 0, '<LastBranch>'), ('/_Help/Functions list', 'F1', functions_help_window, 1, ''), ('/_Help/sep1', None, None, 0, '<Separator>'), ('/_Help/_About', '<control>I', help_menu, 1, '') ]) menubar = itemf.get_widget('<main>') if (gui["disable_menu"] == 0): vbox1.pack_start(menubar, expand=gtk.FALSE) menubar.show() vbox2 = gtk.GtkVBox(spacing=5) vbox1.pack_start(vbox2, expand=gtk.TRUE) vbox2.show() entry = gtk.GtkEntry() gui["main_entry"] = entry vbox2.pack_start(entry, expand=gtk.FALSE) vbox2.set_border_width(4) set_font(entry) if hive.get_bool("/remember_expression", default_remember_expression): entry.set_text( hive.get_string("/last_expression", default_last_expression)) entry.connect("key_press_event", key_function) entry.grab_focus() gui["main_entry"].show() frame = gtk.GtkFrame() vbox2.pack_start(frame) frame.show() vbox3 = gtk.GtkVBox() frame.add(vbox3) vbox3.show() table = gtk.GtkTable(2, 5, gtk.FALSE) table.set_row_spacings(5) table.set_col_spacings(5) table.set_border_width(10) vbox3.pack_start(table) table.show() for y in range(5): label = gtk.GtkLabel(labels[y]) set_font(label) label.show() table.attach(label, 0, 1, y, y + 1) entry = gtk.GtkEntry() gui[entries[y]] = entry entry.set_editable(gtk.FALSE) entry.set_usize(260, -2) set_font(entry) entry.show() table.attach(entry, 1, 2, y, y + 1) gui["main_window"].show() if hive.get_string("/remember_expression", default_remember_expression): result(hive.get_string("/last_expression", default_last_expression)) else: result(0)