diff options
author | Walter Bender <walter@walter-laptop.(none)> | 2009-10-04 16:54:37 (GMT) |
---|---|---|
committer | Walter Bender <walter@walter-laptop.(none)> | 2009-10-04 16:54:37 (GMT) |
commit | 898c047724bd7fa5e6874be25b673594a3100262 (patch) | |
tree | c8587c0140292cb541e808fedeefc5aff4623520 | |
parent | 141e6e82047a2f9a1a4b449fadaf69ce1b1424a4 (diff) |
more adj. to cmdline launch
-rw-r--r-- | NEWS | 1 | ||||
-rwxr-xr-x | cardsort.py | 71 | ||||
-rw-r--r-- | window.py | 10 |
3 files changed, 17 insertions, 65 deletions
@@ -3,6 +3,7 @@ * scaling to different size displays * fixed index bug in test * added blank card for "easy" mode +* sort of, kind of runs from the command line 1 diff --git a/cardsort.py b/cardsort.py index d93fcc6..01a4403 100755 --- a/cardsort.py +++ b/cardsort.py @@ -7,70 +7,15 @@ import os.path import window -class HelloWorld: +def main(): + # All PyGTK applications must have a gtk.main(). Control ends here + # and waits for an event to occur (like a key press or mouse event). + tw = window.new_window(None, \ + os.path.join(os.path.abspath('.'), \ + 'images/card')) + gtk.main() - # This is a callback function. The data arguments are ignored - # in this example. More on callbacks below. - def hello(self, widget, data=None): - print "Hello World" - def delete_event(self, widget, event, data=None): - print "delete event occurred" - return False - - # Another callback - def destroy(self, widget, data=None): - gtk.main_quit() - - def __init__(self): - # create a new window - self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) - self.window.connect("delete_event", self.delete_event) - self.window.connect("destroy", self.destroy) - - # Sets the border width of the window. - self.window.set_border_width(10) - - # Creates a new button with the label "Hello World". - self.button = gtk.Button("Hello World") - - # When the button receives the "clicked" signal, it will call the - # function hello() passing it None as its argument. The hello() - # function is defined above. - self.button.connect("clicked", self.hello, None) - - # This will cause the window to be destroyed by calling - # gtk_widget_destroy(window) when "clicked". Again, the destroy - # signal could come from here, or the window manager. - self.button.connect_object("clicked", gtk.Widget.destroy, self.window) - - # This packs the button into the window (a GTK container). - self.window.add(self.button) - - # The final step is to display this newly created widget. - self.button.show() - - # and the window - self.window.show() - - def main(self): - # All PyGTK applications must have a gtk.main(). Control ends here - # and waits for an event to occur (like a key press or mouse event). - win = gtk.Window(gtk.WINDOW_TOPLEVEL) - # win = gtk.Window() - win.set_has_frame(True) - win.set_decorated(True) - tw = window.new_window(win, \ - os.path.join(os.path.abspath('.'), \ - 'images/card')) - tw.width = gtk.gdk.screen_width() - tw.height = gtk.gdk.screen_height() - win.connect("destroy", lambda w: gtk.main_quit()) - gtk.main() - -# If the program is run directly or passed as an argument to the python -# interpreter then create a HelloWorld instance and show it if __name__ == "__main__": - hello = HelloWorld() - hello.main() + main() @@ -43,18 +43,24 @@ class taWindow: pass # def new_window(canvas, path, parent=None): tw = taWindow() - tw.canvas = canvas tw.path = path tw.activity = parent # starting from command line if parent is None: tw.sugar = False + win = gtk.Window(gtk.WINDOW_TOPLEVEL) + win.set_has_frame(True) + win.set_decorated(True) + tw.canvas = win tw.canvas.set_size_request(gtk.gdk.screen_width(), \ gtk.gdk.screen_height()) - tw.canvas.show_all() + tw.canvas.connect("destroy", lambda w: gtk.main_quit()) + win.show_all() + # starting from Sugar else: tw.sugar = True + tw.canvas = canvas parent.show_all() tw.canvas.set_flags(gtk.CAN_FOCUS) |