Changeset 3074
- Timestamp:
- 07/04/08 10:52:59 (5 years ago)
- Location:
- branch/UmitPlugins
- Files:
-
- 4 modified
-
higwidgets/higtooltips.py (modified) (10 diffs)
-
source-plugins/umit-console/sources/console/console.py (modified) (5 diffs)
-
source-plugins/umit-console/sources/main.py (modified) (1 diff)
-
source-plugins/update.sh (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branch/UmitPlugins/higwidgets/higtooltips.py
r2996 r3074 31 31 self.stock = stock 32 32 self.file = file 33 self.widgets = [] 34 35 def append_widget(self, widget, expand=True, fill=True, padding=0, show=True): 36 self.widgets.append(((widget, expand, fill, padding), show)) 33 37 34 38 class HIGTooltip(gtk.Window): … … 67 71 self._tail_width = 10 68 72 self._tail_offset = 10 69 70 HIGTooltip.__instance = self71 73 72 74 def __create_widgets(self): … … 85 87 self._left = gtk.Label() 86 88 89 self.vbox = gtk.VBox() 90 87 91 def __pack_widgets(self): 88 92 hbox = gtk.HBox(False, 2) … … 91 95 hbox.set_spacing(4) 92 96 93 vbox = gtk.VBox(False, 2) 94 vbox.pack_start(hbox, False, False, 0) 95 vbox.pack_start(gtk.HSeparator(), False, False, 0) 96 vbox.pack_start(self._message, False, False, 0) 97 98 vbox.set_spacing(4) 99 vbox.set_border_width(10) 97 self.vbox.pack_start(hbox, False, False, 0) 98 self.vbox.pack_start(gtk.HSeparator(), False, False, 0) 99 self.vbox.pack_start(self._message, False, False, 0) 100 101 self.vbox.set_spacing(4) 102 self.vbox.set_border_width(10) 100 103 101 104 table = gtk.Table(3, 3) … … 105 108 table.attach(self._right, 2, 3, 0, 3, xoptions=gtk.SHRINK) 106 109 107 table.attach( vbox, 1, 2, 1, 2)110 table.attach(self.vbox, 1, 2, 1, 2) 108 111 109 112 table.show_all() … … 295 298 return (start_x, start_y, _w, _h) 296 299 297 298 #if self._is_top:299 # # Draw bottom300 # if self._is_left:301 # # Draw right302 # cr.move_to(w, h)303 # cr.rel_line_to(-self._tail_width, -self._tail_height + offset)304 # cr.rel_line_to(-self._tail_width * 2, 0)305 # return (w, h)306 # else:307 # # Draw left308 # cr.move_to(x, h)309 # cr.rel_line_to(self._tail_width, -self._tail_height + offset)310 # cr.rel_line_to(self._tail_width * 2, 0)311 # return (x, h)312 #else:313 # # Draw top314 # if self._is_left:315 # # Draw right316 # cr.move_to(w, y)317 # cr.rel_line_to(-self._tail_width, self._tail_height + offset)318 # cr.rel_line_to(-self._tail_width * 2, 0)319 # return (w, y)320 # else:321 # # Draw left322 # cr.move_to(x, y)323 # cr.rel_line_to(self._tail_width, self._tail_height + offset)324 # cr.rel_line_to(self._tail_width * 2, 0)325 # return (x, y)326 327 300 def do_realize(self): 328 301 gtk.Window.do_realize(self) … … 386 359 HIGTooltip.get_instance().widgets[widget] = data 387 360 388 def __show_tooltip(self, w): 361 def show_at(self, w, data, x, y, time=None): 362 """ 363 Show the tooltip at location 364 365 (make x, y optional) 366 """ 367 368 assert (self != HIGTooltip.__instance, \ 369 "You should create another HIGTooltip object to do it") 370 371 if self._timeout_started or \ 372 self.flags() & gtk.VISIBLE or \ 373 self._hover: 374 return False 375 376 # We pack the childs now 377 for child, show in data.widgets: 378 self.vbox.pack_start(*child) 379 380 if show: 381 child[0].show() 382 383 self._hover = w 384 self._timeout_started = True 385 self.__show_tooltip(w, data, x, y) 386 387 if time: 388 self._timeout_id = gobject.timeout_add(time, self.close_and_destroy) 389 390 def close_and_destroy(self): 391 """ 392 Hide the widget resetting values used and also destroy window 393 """ 394 assert (self != HIGTooltip.__instance, \ 395 "You should create another HIGTooltip object to do it") 396 397 self._hover = None 398 self._timeout_started = False 399 400 if self._timeout_id: 401 gobject.source_remove(self._timeout_id) 402 self._timeout_id = None 403 404 self.hide() 405 self.destroy() 406 407 return False 408 409 def __show_tooltip(self, w, data=None, x=None, y=None): 389 410 if not self._timeout_started or \ 390 411 self.flags() & gtk.VISIBLE or \ … … 392 413 return False 393 414 394 window = w.get_parent_window() 395 396 x, y = window.get_position() 397 px, py, pmask = window.get_pointer() 398 399 x += px; y += py 415 if not data: 416 window = w.get_parent_window() 417 418 x, y = window.get_position() 419 px, py, pmask = window.get_pointer() 420 421 x += px; y += py 422 400 423 rect = w.get_allocation() 401 424 … … 412 435 else: self._is_top = False 413 436 414 data = self._widgets[w] 437 if not data: 438 data = self._widgets[w] 415 439 416 440 self.title = data.title … … 451 475 "Return the instance of HIGTooltip" 452 476 if not HIGTooltip.__instance: 453 HIGTooltip ()477 HIGTooltip.__instance = HIGTooltip() 454 478 455 479 return HIGTooltip.__instance -
branch/UmitPlugins/source-plugins/umit-console/sources/console/console.py
r3033 r3074 50 50 import gtk 51 51 import pango 52 import gobject 52 53 53 54 # Completions stuff … … 212 213 """ Interactive GTK console class """ 213 214 215 __gsignals__ = { 216 'eval' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_BOOLEAN, (gobject.TYPE_STRING, )) 217 } 218 214 219 def __init__(self, namespace={}, quit_handler = None): 215 220 """ Initialize console … … 400 405 self.prompt1() 401 406 407 def append_text(self, txt): 408 iter = self.buffer.get_iter_at_mark(self.buffer.get_insert()) 409 self.buffer.insert_with_tags_by_name(iter, txt, 'normal') 410 self.text.scroll_to_mark (self.buffer.get_insert(), 0) 402 411 403 412 def prompt1 (self): … … 560 569 def execute (self, cmd): 561 570 """ Execute a given command """ 571 572 if self.emit('eval', cmd): 573 return 562 574 563 575 sys.stdout, self.stdout = self.stdout, sys.stdout … … 733 745 return False 734 746 735 747 gobject.type_register(Console) 736 748 737 749 # ============================================================================= -
branch/UmitPlugins/source-plugins/umit-console/sources/main.py
r3033 r3074 29 29 30 30 from umitPlugin.Engine import Plugin 31 from higwidgets.higtooltips import HIGTooltip, HIGTooltipData 31 32 32 33 class ConsoleView(UmitView): 33 34 label_text = "Umit Shell" 34 35 35 36 def create_ui(self): 36 37 con = console.Console(globals()) 37 38 con.banner() 38 39 40 con.connect('eval', self.__on_help) 41 39 42 self._main_widget.add(con) 40 43 self._main_widget.show_all() 44 45 def __on_help(self, console, cmd): 46 print console, cmd 47 48 cmd = cmd.replace("\n", "") 49 50 if cmd == "help": 51 console.append_text("Have you called help?\n") 52 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) 63 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 return True 76 77 return False 41 78 42 79 class ConsolePlugin(Plugin): -
branch/UmitPlugins/source-plugins/update.sh
r3018 r3074 8 8 dir=`dirname $current` 9 9 10 for i in */ 11 do 12 cd ${current}/${i} 13 PYTHONPATH=$dir:$PYTHONPATH python setup.py install 10 if [ -e "$1" ]; then 11 cd ${current}/$1 12 PYTHONPATH=$dir:$PYTHONPATH python setup.py install --no-compile 14 13 mv *.ump ../ 15 done 14 else 15 for i in */ 16 do 17 cd ${current}/${i} 18 PYTHONPATH=$dir:$PYTHONPATH python setup.py install --no-compile 19 mv *.ump ../ 20 done 21 fi 16 22 17 23 echo
