Exemplo n.º 1
0
 def file_open(self, mi=None):
     fname = GtkExtra.file_open_box(modal=FALSE)
     if fname:
         ew = edit.EditWindow(quit_cb=self.rem_editwin)
         ew.load_file(fname)
         self.editwins.append(ew)
         self.add_py_menu(ew)
         ew.show()
         ew.set_usize(0, 0)
Exemplo n.º 2
0
	def file_open(self, mi=None):
		fname = GtkExtra.file_open_box(modal=FALSE)
		if fname:
			ew = edit.EditWindow(quit_cb=self.rem_editwin)
			ew.load_file(fname)
			self.editwins.append(ew)
			self.add_py_menu(ew)
			ew.show()
			ew.set_usize(0,0)
Exemplo n.º 3
0
 def process_file(self, action, widget):
     if action == 0:
         print "File:<unknwon>"
     elif action == 1:
         print "File:New"
     elif action == 2:
         print "File:Open"
         print GtkExtra.file_open_box(modal=FALSE), "chosen"
     elif action == 3:
         print "FileSave"
         dlg = GtkExtra.message_box("Test Application", "Not implemented", ("OK",), pixmap="bomb.xpm")
     elif action == 4:
         print "File:Save As"
         print GtkExtra.file_save_box(modal=FALSE), "chosen"
     elif action == 5:
         print "File:Close"
     elif action == 6:
         print "File:Exit"
         mainquit()
Exemplo n.º 4
0
class Application:
    def __init__(self, argv):
        self.w_window = GtkWindow(title="Test Application")
        self.w_window.set_border_width(10)
        self.w_vbox = GtkVBox()

        self.init_menu()
        self.init_text()

        self.w_window.add(self.w_vbox)
        self.w_vbox.show()
        self.w_window.show()

    def mainloop(self):
        mainloop()

    def init_menu(self):
        ag = GtkAccelGroup()
        itemf = GtkItemFactory(GtkMenuBar, "<main>", ag)
        self.w_window.add_accel_group(ag)
        file_cb = self.process_file
        edit_cb = self.process_edit
        itemf.create_items([('/_File', None, None, 0, '<Branch>'),
                            ('/_File/_New', '<control>N', file_cb, 1, ''),
                            ('/_File/_Open', '<control>O', file_cb, 2, ''),
                            ('/_File/_Save', '<control>S', file_cb, 3, ''),
                            ('/_File/Save _As', None, file_cb, 4, ''),
                            ('/_File/_Close', None, file_cb, 5, ''),
                            ('/_File/sep1', None, file_cb, 0, '<Separator>'),
                            ('/_File/E_xit', '<alt>F4', file_cb, 6, ''),
                            ('/_Edit', None, None, 0, '<Branch>'),
                            ('/_Edit/C_ut', '<control>X', edit_cb, 1, ''),
                            ('/_Edit/_Copy', '<control>C', edit_cb, 2, ''),
                            ('/_Edit/_Paste', '<control>V', edit_cb, 3, '')])
        self.w_menubar = itemf.get_widget('<main>')
        self.w_vbox.pack_start(self.w_menubar, expand=FALSE)
        self.w_menubar.show()

    def init_text(self):
        self.w_table = GtkTable(2, 2, 0)
        self.w_table.show()

        self.w_text = GtkText()
        self.w_text.set_usize(350, 250)
        ## Note: editable text is disable in gtk+-971109
        self.w_text.set_editable(1)
        self.w_table.attach(self.w_text, 0, 1, 0, 1, xpadding=1, ypadding=1)
        self.w_text.show()

        self.w_hscrollbar = GtkHScrollbar(self.w_text.get_hadjustment())
        self.w_table.attach(self.w_hscrollbar, 0, 1, 1, 2, yoptions=FILL)
        self.w_hscrollbar.show()

        self.w_vscrollbar = GtkVScrollbar(self.w_text.get_vadjustment())
        self.w_table.attach(self.w_vscrollbar, 1, 2, 0, 1, xoptions=FILL)
        self.w_vscrollbar.show()

        self.w_vbox.pack_start(self.w_table)

    def process_file(self, action, widget):
        if action == 0: print "File:<unknown>"
        elif action == 1:
            print "File:New"
            self.w_text.freeze()
            self.w_text.set_point(0)
            self.w_text.insert_defaults("*new file*")
            self.w_text.thaw()
            #self.w_text.queueDraw()
        elif action == 2:
            print "File:Open"
            fname = GtkExtra.file_open_box(modal=FALSE)
            if fname:
                try:
                    f = open(fname, "r")
                except IOError:
                    return
                self.w_text.freeze()
                while TRUE:
                    line = f.readline()
                    if line == "":
                        break
                    self.w_text.insert_defaults(line)
                self.w_text.thaw()
Exemplo n.º 5
0
class Application:
    def __init__(self, argv):

        # hardcoded font - maybe not on every server ?
        self.medium_fonts = [
            "lucidasanstypewriter-10", "lucidasanstypewriter-12",
            "lucidasanstypewriter-14", "lucidasanstypewriter-18",
            "lucidasanstypewriter-24"
        ]
        self.bold_fonts = [
            "lucidasanstypewriter-bold-10", "lucidasanstypewriter-bold-12",
            "lucidasanstypewriter-bold-14", "lucidasanstypewriter-bold-18",
            "lucidasanstypewriter-bold-24"
        ]
        self.font_type = 0
        self.font_index = 0
        # dictionary of loaded fonts
        self.fonts = {}

        self.w_window = GtkWindow()
        self.w_window.set_title("Test application")
        self.w_window.set_border_width(10)
        self.w_vbox = GtkVBox()

        self.init_menu()
        self.init_text()

        self.w_window.add(self.w_vbox)
        self.w_vbox.show()
        self.w_window.show()

    def mainloop(self):
        mainloop()

    def init_menu(self):
        ag = GtkAccelGroup()
        itemf = GtkItemFactory(GtkMenuBar, "<main>", ag)
        self.w_window.add_accel_group(ag)
        file_cb = self.process_file
        edit_cb = self.process_edit
        help_cb = self.process_help
        itemf.create_items([('/_File', None, None, 0, '<Branch>'),
                            ('/_File/_New', '<control>N', file_cb, 1, ''),
                            ('/_File/_Open', '<control>O', file_cb, 2, ''),
                            ('/_File/_Save', '<control>S', file_cb, 3, ''),
                            ('/_File/Save _As', None, file_cb, 4, ''),
                            ('/_File/_Close', None, file_cb, 5, ''),
                            ('/_File/sep1', None, file_cb, 0, '<Separator>'),
                            ('/_File/E_xit', '<alt>F4', file_cb, 6, ''),
                            ('/_Edit', None, None, 0, '<Branch>'),
                            ('/_Edit/C_ut', '<control>X', edit_cb, 1, ''),
                            ('/_Edit/_Copy', '<control>C', edit_cb, 2, ''),
                            ('/_Edit/_Paste', '<control>V', edit_cb, 3, ''),
                            ('/_Help', None, None, 0, '<LastBranch>'),
                            ('/_Help/_About', '<control>A', help_cb, 1, '')])
        self.w_menubar = itemf.get_widget('<main>')
        self.w_vbox.pack_start(self.w_menubar, expand=FALSE)
        self.w_menubar.show()

    def init_text(self):
        self.w_table = GtkTable(2, 2, 0)
        self.w_table.show()

        self.w_text = GtkText()
        self.w_text.set_usize(350, 250)
        ## Note: editable text is disable in gtk+-971109
        self.w_text.set_editable(0)
        self.w_table.attach(self.w_text, 0, 1, 0, 1, xpadding=1, ypadding=1)
        self.w_text.show()

        self.w_text.connect("key_press_event", self.process_key)
        self.w_text.set_events(GDK.KEY_PRESS_MASK)

        self.w_hscrollbar = GtkHScrollbar(self.w_text.get_hadjustment())
        self.w_table.attach(self.w_hscrollbar, 0, 1, 1, 2, yoptions=FILL)
        self.w_hscrollbar.show()

        self.w_vscrollbar = GtkVScrollbar(self.w_text.get_vadjustment())
        self.w_table.attach(self.w_vscrollbar, 1, 2, 0, 1, xoptions=FILL)
        self.w_vscrollbar.show()

        self.w_vbox.pack_start(self.w_table)

    def process_file(self, action, widget):
        if action == 0: print "File:<unknown>"
        elif action == 1:
            print "File:New"
            self.w_text.freeze()
            self.w_text.set_point(0)
            self.w_text.insert_defaults("*new file*")
            self.w_text.thaw()
            #self.w_text.queueDraw()
        elif action == 2:
            print "File:Open"
            print GtkExtra.file_open_box(modal=FALSE), "chosen"
Exemplo n.º 6
0
class Application:		
	def __init__(self, argv):
		self.w_window=GtkWindow(title="Test Application")
		self.w_window.set_border_width(10)
		self.w_vbox=GtkVBox()

		self.init_menu()
		self.init_canvas()
		
		self.w_window.add(self.w_vbox)
		self.w_vbox.show()
		self.w_window.show()
		
	def mainloop(self):
		mainloop()

	def init_menu(self):
		ag = GtkAccelGroup()
		itemf = GtkItemFactory(GtkMenuBar, "<main>", ag)
		self.w_window.add_accel_group(ag)
		file_cb = self.process_file
		edit_cb = self.process_edit
		help_cb = self.process_help
		itemf.create_items([
			('/_File',          None,         None, 0, '<Branch>'),
			('/_File/_New',     '<control>N', file_cb, 1, ''),
			('/_File/_Open',    '<control>O', file_cb, 2, ''),
			('/_File/_Save',    '<control>S', file_cb, 3, ''),
			('/_File/Save _As', None,         file_cb, 4, ''),
			('/_File/_Close',   None,         file_cb, 5, ''),
			('/_File/sep1',     None,   file_cb, 0, '<Separator>'),
			('/_File/E_xit',    '<alt>F4',    file_cb, 6, ''),
			('/_Edit',          None,         None, 0, '<Branch>'),
			('/_Edit/C_ut',     '<control>X', edit_cb, 1, ''),
			('/_Edit/_Copy',    '<control>C', edit_cb, 2, ''),
			('/_Edit/_Paste',   '<control>V', edit_cb, 3, ''),
			('/_Help',          None,         None, 0, '<LastBranch>'),
			('/_Help/_About',   '<control>A', help_cb, 1, '')
		])
		self.w_menubar = itemf.get_widget('<main>')
		self.w_vbox.pack_start(self.w_menubar, expand=FALSE)
		self.w_menubar.show()

	def init_canvas(self):		
		self.w_canvas=GtkDrawingArea()
		self.w_canvas.size(350,250)
		self.w_canvas.show()
		self.w_vbox.pack_start(self.w_canvas)
				
		self.w_canvas.connect("button_press_event", self.process_button)
		self.w_canvas.connect("motion_notify_event", self.process_motion)
		self.w_canvas.connect("key_press_event", self.process_key)
		self.w_canvas.set_events(GDK.BUTTON_PRESS_MASK |
					 GDK.POINTER_MOTION_MASK |
					 GDK.POINTER_MOTION_HINT_MASK |
					 GDK.KEY_PRESS_MASK)
					
	def process_file(self, action, widget):
		if action == 0: print "File:<unknwon>"
		elif action == 1:
			print "File:New"
		elif action == 2:
			print "File:Open"
			print GtkExtra.file_open_box(modal=FALSE), "chosen"
Exemplo n.º 7
0
 def file_open(self, mi=None):
     if self.chk_save(): return
     fname = GtkExtra.file_open_box(modal=FALSE)
     if not fname: return
     self.load_file(fname)
Exemplo n.º 8
0
	def file_open(self, mi=None):
		if self.chk_save(): return
		fname = GtkExtra.file_open_box(modal=FALSE)
		if not fname: return
		self.load_file(fname)
Exemplo n.º 9
0
 def open_choices(self, mi):
     filename = GtkExtra.file_open_box(modal=FALSE)
     self.choices_filename = filename
     self.reload_choices()