Changeset 3093
- Timestamp:
- 07/07/08 15:10:11 (5 years ago)
- Location:
- branch/UmitPlugins
- Files:
-
- 4 modified
-
higwidgets/higtooltips.py (modified) (3 diffs)
-
source-plugins/umit-console/sources/console/console.py (modified) (5 diffs)
-
source-plugins/umit-console/sources/main.py (modified) (2 diffs)
-
umitPlugin/Core.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branch/UmitPlugins/higwidgets/higtooltips.py
r3074 r3093 49 49 Create a HIGTooltip object 50 50 """ 51 gtk.Window.__init__(self, gtk.WINDOW_POPUP) 51 gtk.Window.__init__(self)#, gtk.WINDOW_POPUP) 52 self.set_decorated(False) 52 53 53 54 self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_MENU) # should be tooltip … … 381 382 child[0].show() 382 383 384 w.get_toplevel().connect('configure-event', self.__close_on_event) 385 383 386 self._hover = w 384 387 self._timeout_started = True … … 387 390 if time: 388 391 self._timeout_id = gobject.timeout_add(time, self.close_and_destroy) 392 def __close_on_event(self, w, event): 393 self.close_and_destroy() 389 394 390 395 def close_and_destroy(self): -
branch/UmitPlugins/source-plugins/umit-console/sources/console/console.py
r3074 r3093 358 358 359 359 iter = self.buffer.get_iter_at_mark(self.buffer.get_insert()) 360 self.buffer.insert (iter, '\n')360 self.buffer.insert_with_tags_by_name(iter, '\n', 'normal') 361 361 362 362 width = max(self.get_width(), 4) … … 383 383 else: 384 384 n_spaces = col_width - len(completions[ind]) 385 self.buffer.insert(iter, completions[ind] + " " * n_spaces) 386 self.buffer.insert(iter, "\n") 385 self.buffer.insert_with_tags_by_name( \ 386 iter, completions[ind] + " " * n_spaces, 'normal') 387 self.buffer.insert_with_tags_by_name(iter, '\n', 'normal') 387 388 388 389 self.write (self.prompt, 'prompt') … … 526 527 527 528 l = self.current_line() 528 self.write ('\n' )529 self.write ('\n', 'normal') 529 530 self.history.append (l) 530 531 end = self.buffer.get_end_iter() … … 621 622 for line in f: 622 623 self.write ('\t'+line, 'script') 623 self.write ('\n' )624 self.write ('\n', 'normal') 624 625 self.execute ("execfile('%s')" % filename) 625 626 self.prompt1() … … 660 661 self.buffer.apply_tag_by_name('script', start, end) 661 662 662 self.write('\n' )663 self.write('\n', 'normal') 663 664 else: 664 665 start, end = self.current_line_bounds() -
branch/UmitPlugins/source-plugins/umit-console/sources/main.py
r3074 r3093 28 28 from tabber.views import UmitView 29 29 30 from umitCore.I18N import _ 30 31 from umitPlugin.Engine import Plugin 32 from umitPlugin.Atoms import Singleton 33 from higwidgets.higbuttons import HIGButton 31 34 from higwidgets.higtooltips import HIGTooltip, HIGTooltipData 35 36 help_strings = [ 37 _("This is the help system of umitConsole.\n" 38 "Now i'll show you some umit funcionality\n\n\n" + 39 "<i>Press <b>Close</b> or <b>Next</b> to continue</i>\n"), 40 41 _("Ok, let's introduce myself. The window above is a Python prompt.\n" 42 "Type a line of Python code, hit <i>Enter</i> and watch it run!\n\n" 43 "For example try typing some math. Like <tt>2 + 6</tt>\n"), 44 45 _("It could handle everything that Python supports. But it is also\n" 46 "used to interact with <b>UMIT</b> codebase and his <i>UI</i>.\n" 47 "For example try typing:\n\n" 48 "<tt>from umitPlugin.Core import Core</tt>\n" 49 "<tt>Core().get_main_toolbar().hide()</tt>\n") 50 ] 51 52 53 class MiniButton(gtk.Button): 54 def __init__(self, stock): 55 gtk.Button.__init__(self) 56 57 img = gtk.image_new_from_stock(stock, gtk.ICON_SIZE_MENU) 58 img.show() 59 60 self.add(img) 61 self.set_relief(gtk.RELIEF_NONE) 62 self.connect('size-allocate', self.__size_allocate) 63 64 def __size_allocate(self, widget, alloc): 65 alloc.width = alloc.height 66 return gtk.Button.do_size_allocate(self, alloc) 67 68 class Help(object): 69 def __init__(self, console): 70 self.index = 0 71 self.array = help_strings 72 self.console = console 73 self.tip = None 74 75 def next(self): 76 if self.index < len(self.array) - 1: 77 self.index += 1 78 79 def previous(self): 80 if self.index > 0: 81 self.index -= 1 82 83 def current(self): 84 string = self.array[self.index] 85 data = HIGTooltipData(string) 86 87 hbb = gtk.HBox(2, False) 88 89 btn = MiniButton(stock=gtk.STOCK_CLOSE) 90 btn.connect('clicked', self.__on_close) 91 hbb.pack_start(btn, False, False, 0) 92 93 btn = MiniButton(stock=gtk.STOCK_GO_BACK) 94 btn.connect('clicked', self.__on_back) 95 96 if self.index == 0: 97 btn.set_sensitive(False) 98 99 hbb.pack_start(btn, False, False, 0) 100 101 btn = MiniButton(stock=gtk.STOCK_GO_FORWARD) 102 btn.connect('clicked', self.__on_forward) 103 104 if self.index == len(self.array) - 1: 105 btn.set_sensitive(False) 106 107 hbb.pack_start(btn, False, False, 0) 108 109 hbb.show_all() 110 111 align = gtk.Alignment(1.0, 0.5) 112 align.add(hbb) 113 114 align.show_all() 115 116 data.append_widget(align) 117 118 return data 119 120 def __on_back(self, widget): 121 self.previous() 122 self.__on_close(widget) 123 self.show_help() 124 125 def __on_forward(self, widget): 126 self.next() 127 self.__on_close(widget) 128 self.show_help() 129 130 def __on_close(self, widget): 131 if self.tip: 132 self.tip.close_and_destroy() 133 134 def show_help(self): 135 self.__on_close(None) 136 self.tip = HIGTooltip() 137 x, y = self.console.window.get_origin() 138 self.tip.show_at(self.console, self.current(), x, y) 32 139 33 140 class ConsoleView(UmitView): … … 35 142 36 143 def create_ui(self): 37 con = console.Console(globals()) 38 con.banner() 144 self.console = console.Console(globals()) 145 self.console.connect('eval', self.__on_help) 146 self.console.banner() 39 147 40 con.connect('eval', self.__on_help)148 self.help = Help(self.console) 41 149 42 self._main_widget.add( con)150 self._main_widget.add(self.console) 43 151 self._main_widget.show_all() 44 152 45 153 def __on_help(self, console, cmd): 46 print console, cmd47 48 154 cmd = cmd.replace("\n", "") 49 155 50 156 if cmd == "help": 51 console.append_text("Have you called help?\n")157 #console.append_text("Have you called help?\n") 52 158 53 data = HIGTooltipData( 54 "This is the help system of umitConsole.\n" 55 "Now i'll show you some umit funcionality\n\n\n" + 56 "<i>Press <b>Close</b> or <b>Next</b> to continue</i>\n") 57 58 hbb = gtk.HButtonBox() 59 hbb.set_layout(gtk.BUTTONBOX_END) 60 61 btn = gtk.Button(stock=gtk.STOCK_CLOSE) 62 hbb.pack_start(btn) 159 self.help.show_help() 63 160 64 btn = gtk.Button(stock=gtk.STOCK_GO_FORWARD)65 hbb.pack_start(btn)66 67 hbb.show_all()68 data.append_widget(hbb)69 70 x, y = console.window.get_origin()71 72 tip = HIGTooltip()73 tip.show_at(console, data, x, y, 10000)74 75 161 return True 76 162 -
branch/UmitPlugins/umitPlugin/Core.py
r3090 r3093 109 109 110 110 def open_url(self, link): 111 """ 112 Open the default browser at link location 113 114 @param link the link to open 115 """ 116 111 117 import webbrowser 112 118
