Ejemplo n.º 1
0
 def _cancel(self, w, client_data, call_data):
     ToolTip.rmtt()
     if self.is_closed():
         return
     self.close()
     if client_data:
         apply(apply, client_data)
         toplevel.setready()
Ejemplo n.º 2
0
 def _ok(self, w, client_data, call_data):
     ToolTip.rmtt()
     if self.is_closed():
         return
     value = call_data.value
     self.close()
     if client_data:
         client_data(value)
         toplevel.setready()
Ejemplo n.º 3
0
 def _callback(self, widget, callback, call_data):
     ToolTip.rmtt()
     if not self._main:
         return
     if callback:
         apply(apply, callback)
     if self._grab:
         self.close()
     toplevel.setready()
Ejemplo n.º 4
0
 def __callback(self, widget, callback, call_data):
     ToolTip.rmtt()
     if type(callback) is ClassType:
         callback = self.__commanddict.get(callback)
         if callback is not None:
             callback = callback.callback
     label = self.__togglelables.get(widget)
     if label is not None:
         widget.labelString = label[widget.ToggleButtonGetState()]
     if callback is not None:
         apply(apply, callback)
         toplevel.setready()
Ejemplo n.º 5
0
 def _cancel_callback(self, *rest):
     ToolTip.rmtt()
     if self.is_closed():
         return
     must_close = TRUE
     try:
         if self.cb_cancel:
             ret = self.cb_cancel()
             if ret:
                 if type(ret) is StringType:
                     showmessage(ret, parent=self)
                 must_close = FALSE
                 return
     finally:
         if must_close:
             self.close()
         toplevel.setready()
Ejemplo n.º 6
0
 def create_box(self,
                msg,
                callback,
                box=None,
                units=UNIT_SCREEN,
                modeless=0):
     import Xcursorfont
     if modeless:
         if not box:
             raise error, 'can only be modeless with box'
     if self._in_create_box and not self._in_create_box.is_closed():
         self._in_create_box.cancel_create_box()
     if self.is_closed():
         apply(callback, ())
         return
     _RubberBand._in_create_box = self
     self._ignore_rb = 0
     self.pop(poptop=0)
     self.__dl = self._active_displist
     if self.__dl:
         d = self.__dl.clone()
     else:
         d = self.newdisplaylist()
     self.__transparent = []
     sw = self._subwindows[:]
     sw.reverse()
     r = Xlib.CreateRegion()
     for win in sw:
         if not win._transparent:
             # should do this recursively...
             self.__transparent.append(win)
             win._transparent = 1
             d.drawfbox(win._bgcolor, win._sizes)
             apply(r.UnionRectWithRegion, win._rect)
     for win in sw:
         b = win._sizes
         if b != (0, 0, 1, 1):
             d.drawbox(b)
     self.__display = d.clone()
     if box:
         self.__drawbox(d, SELCOLOR, box, units)
     if self.__transparent:
         self._do_expose(r)
         self.__reg = r
     d.render()
     self.__curdisp = d
     if msg:
         msg = msg + '\n\n' + _rb_message
     else:
         msg = _rb_message
     self.__callback = callback
     self.__units = units
     form = self._form
     cursor = form.Display().CreateFontCursor(Xcursorfont.crosshair)
     if not modeless:
         self.__dialog = showmessage(msg,
                                     mtype='message',
                                     grab=0,
                                     callback=(self.__done, ()),
                                     cancelCallback=(self.cancel_create_box,
                                                     ()))
         self.__dialog._main.AddGrab(1, 0)
         form.AddGrab(0, 0)
         toplevel.setcursor('stop')
         self._topwindow.setcursor('')
         self.__dialog.setcursor('')
     else:
         self.__dialog = None
     form.RemoveEventHandler(X.PointerMotionMask, FALSE,
                             self._motion_handler, None)
     form.AddEventHandler(X.ButtonPressMask, FALSE, self.__start, None)
     form.AddEventHandler(X.ButtonMotionMask, FALSE, self.__do, None)
     form.AddEventHandler(X.ButtonReleaseMask, FALSE, self.__end, None)
     form.GrabButton(
         X.AnyButton, X.AnyModifier, TRUE,
         X.ButtonPressMask | X.ButtonMotionMask
         | X.ButtonReleaseMask, X.GrabModeAsync, X.GrabModeAsync, form,
         cursor)
     v = form.GetValues(['foreground', 'background'])
     v['foreground'] = v['foreground'] ^ v['background']
     v['function'] = X.GXxor
     v['line_style'] = X.LineOnOffDash
     self.__gc = form.GetGC(v)
     if box:
         x, y, w, h = self._convert_coordinates(box, units=units)
         if w < 0:
             x, w = x + w, -w
         if h < 0:
             y, h = y + h, -h
         self.__box = 1
         self.__start_x = x
         self.__start_y = y
         self.__width = w
         self.__height = h
     else:
         self.__start_x, self.__start_y, self.__width, \
                           self.__height = self._rect
         self.__box = 0
     self.__looping = 1
     toplevel.setready()
     if not modeless:
         while self.__looping:
             Xt.DispatchEvent(Xt.NextEvent())
Ejemplo n.º 7
0
 def __callback(self, widget, callback, call_data):
     if callback:
         callback(self.__descriptions[self.__index])
     self.__window.DestroyWidget()
     toplevel.setready()
Ejemplo n.º 8
0
 def _ok_callback(self, widget, existing, call_data):
     ToolTip.rmtt()
     if self.is_closed():
         return
     self._do_ok_callback(widget, existing, call_data)
     toplevel.setready()
Ejemplo n.º 9
0
 def __init__(self,
              text,
              mtype='message',
              grab=1,
              callback=None,
              cancelCallback=None,
              name='message',
              title='message',
              parent=None,
              identity=None):
     # XXXX If identity != None the user should have the option of not
     # showing this message again
     if grab:
         dialogStyle = Xmd.DIALOG_FULL_APPLICATION_MODAL
         if parent is None:
             parent = toplevel
         while 1:
             if hasattr(parent, '_shell'):
                 parent = parent._shell
                 break
             if hasattr(parent, '_main'):
                 parent = parent._main
                 break
             if hasattr(parent, '_parent'):
                 parent = parent._parent
             else:
                 parent = toplevel
     else:
         dialogStyle = Xmd.DIALOG_MODELESS
         parent = toplevel._main
     if mtype == 'error':
         func = parent.CreateErrorDialog
     elif mtype == 'warning':
         func = parent.CreateWarningDialog
     elif mtype == 'information':
         func = parent.CreateInformationDialog
     elif mtype == 'question':
         func = parent.CreateQuestionDialog
     else:
         func = parent.CreateMessageDialog
     self._grab = grab
     w = func(
         name, {
             'messageString': text,
             'title': title,
             'dialogStyle': dialogStyle,
             'resizePolicy': Xmd.RESIZE_NONE,
             'visual': toplevel._default_visual,
             'depth': toplevel._default_visual.depth,
             'colormap': toplevel._default_colormap
         })
     w.MessageBoxGetChild(Xmd.DIALOG_HELP_BUTTON).UnmanageChild()
     if mtype == 'question' or cancelCallback:
         w.AddCallback('cancelCallback', self._callback, cancelCallback)
         w.Parent().AddWMProtocolCallback(toplevel._delete_window,
                                          self._callback, cancelCallback)
     else:
         w.MessageBoxGetChild(Xmd.DIALOG_CANCEL_BUTTON).UnmanageChild()
     w.AddCallback('okCallback', self._callback, callback)
     w.AddCallback('destroyCallback', self._destroy, None)
     w.ManageChild()
     self._main = w
     self.setcursor(_WAITING_CURSOR)
     toplevel._subwindows.append(self)
     if grab:
         toplevel.setready()
         while self._grab:
             Xt.DispatchEvent(Xt.NextEvent())