Esempio n. 1
0
    def __init__(self,
                 names,
                 descriptions,
                 cb,
                 cancelCallback=None,
                 parent=None):
        # names: list of template names
        # descriptions: list of (text, image, ...) parallel to names
        #
        # First create dialogwindow and set static items
        DialogWindow.__init__(self,
                              self.DIALOG_ID,
                              title="New Document",
                              default=ITEM_TEMPLATE_OK,
                              cancel=ITEM_TEMPLATE_CANCEL)

        self.type_select = self.SelectWidget(ITEM_TEMPLATE_POPUP, names)
        self.snapshot = self.ImageWidget(ITEM_TEMPLATE_IMAGE)
        self._cb = cb
        self._cancel = cancelCallback
        self.descriptions = descriptions

        self.type_select.select(0)
        self._setdialoginfo(0)
        ##         self.settarget(ITEM_TEMPLATE_PLAYER)

        self.show()
Esempio n. 2
0
 def __init__(self, title, parent=None):
     DialogWindow.__init__(self,
                           ID_DIALOG_BANDWIDTH,
                           default=ITEM_BANDWIDTH_OK,
                           cancel=ITEM_BANDWIDTH_CANCEL)
     self._settext(ITEM_BANDWIDTH_MESSAGE, title)
     self._settext(ITEM_BANDWIDTH_ERRORS, 'Computing...')
     self._settext(ITEM_BANDWIDTH_STALLTIME, 'Computing...')
     self._settext(ITEM_BANDWIDTH_STALLCOUNT, 'Computing...')
     self._settext(ITEM_BANDWIDTH_PREROLL, 'Computing...')
     self._settext(ITEM_BANDWIDTH_MESSAGE2, '')
     self.mustwait = 0
     self.calback = None
     ctl = self._dlg.GetDialogItemAsControl(ITEM_BANDWIDTH_OK)
     ctl.DeactivateControl()
     ctl = self._dlg.GetDialogItemAsControl(ITEM_BANDWIDTH_CANCEL)
     ctl.DeactivateControl()
     self.show()
     self._dlg.DrawDialog()
Esempio n. 3
0
 def __init__(self,
              prompt,
              default,
              types,
              cb,
              cancelCallback=None,
              parent=None):
     # First create dialogwindow and set static items
     DialogWindow.__init__(self,
                           self.DIALOG_ID,
                           title=prompt,
                           default=ITEM_INPUT_OK,
                           cancel=ITEM_INPUT_CANCEL)
     h = self._dlg.GetDialogItemAsControl(ITEM_INPUT_TEXT)
     Dlg.SetDialogItemText(h, _string2dialog(default))
     self._dlg.SelectDialogItemText(ITEM_INPUT_TEXT, 0, 32767)
     self.type_select = self.SelectWidget(ITEM_NEWCHANNEL_TYPE, types)
     self._cb = cb
     self._cancel = cancelCallback
Esempio n. 4
0
 def __init__(self,
              title,
              resid,
              allitems=[],
              default=None,
              cancel=None,
              cmdbuttons=None):
     self._itemlist_shown = allitems[:]
     if not hasattr(self, 'last_geometry'):
         self.last_geometry = None
     self._window = DialogWindow(resid,
                                 title=title,
                                 default=default,
                                 cancel=cancel,
                                 cmdbuttons=cmdbuttons,
                                 geometry=self.last_geometry)
     self._dialog = self._window.getdialogwindowdialog()
     # Override event handler:
     self._window.set_itemhandler(self.do_itemhit)
Esempio n. 5
0
    def __init__(self,
                 listprompt,
                 itemlist,
                 default=None,
                 hascancel=1,
                 show=1,
                 multi=0):
        # First create dialogwindow and set static items
        if hascancel:
            DialogWindow.__init__(self,
                                  self.DIALOG_ID,
                                  default=ITEM_SELECT_OK,
                                  cancel=ITEM_SELECT_CANCEL)
        else:
            DialogWindow.__init__(self, self.DIALOG_ID, default=ITEM_SELECT_OK)
        if not hascancel:
            self._dlg.HideDialogItem(ITEM_SELECT_CANCEL)
        h = self._dlg.GetDialogItemAsControl(ITEM_SELECT_LISTPROMPT)
        Dlg.SetDialogItemText(h, _string2dialog(listprompt))

        # Now setup the scrolled list
        self._itemlist = itemlist
        self._listwidget = self.ListWidget(ITEM_SELECT_ITEMLIST,
                                           itemlist,
                                           multi=multi)
        self._listwidget.setkeyboardfocus()

        # And the default value and ok button
        ctl = self._dlg.GetDialogItemAsControl(ITEM_SELECT_OK)
        if multi:
            ctl.ActivateControl()
        elif default is None:
            ctl.DeactivateControl()
        else:
            ctl.ActivateControl()
            self._listwidget.select(default)

        # And show it
        if show:
            self.show()
Esempio n. 6
0
    def __init__(self,
                 prompt,
                 default,
                 cb,
                 cancelCallback=None,
                 passwd=0,
                 parent=None):
        # XXXX passwd parameter to be implemted
        self._is_passwd_dialog = passwd
        # First create dialogwindow and set static items
        if passwd:
            dialog_id = ID_PASSWD_DIALOG
        else:
            dialog_id = self.DIALOG_ID
        DialogWindow.__init__(self,
                              dialog_id,
                              title=prompt,
                              default=ITEM_INPUT_OK,
                              cancel=ITEM_INPUT_CANCEL)
        self._settext(default)
        self._cb = cb
        self._cancel = cancelCallback

        self.show()
Esempio n. 7
0
 def close(self):
     self.grabdone()
     self.type_select.delete()
     del self.type_select
     del self.snapshot
     DialogWindow.close(self)
Esempio n. 8
0
class MACDialog:
    def __init__(self,
                 title,
                 resid,
                 allitems=[],
                 default=None,
                 cancel=None,
                 cmdbuttons=None):
        self._itemlist_shown = allitems[:]
        if not hasattr(self, 'last_geometry'):
            self.last_geometry = None
        self._window = DialogWindow(resid,
                                    title=title,
                                    default=default,
                                    cancel=cancel,
                                    cmdbuttons=cmdbuttons,
                                    geometry=self.last_geometry)
        self._dialog = self._window.getdialogwindowdialog()
        # Override event handler:
        self._window.set_itemhandler(self.do_itemhit)

    def get_geometry(self):
        if self._window and self._window.is_showing():
            self.last_geometry = self._window.getgeometry(mw_globals.UNIT_PXL)
            return self.last_geometry

    def do_itemhit(self, item, event):
        return 0

    def _showitemlist(self, itemlist):
        """Make sure the items in itemlist are visible and active. NOTE: obsolete"""
        for item in itemlist:
            if item in self._itemlist_shown:
                continue
            self._dialog.ShowDialogItem(item)
            tp, h, rect = self._dialog.GetDialogItem(
                item)  # XXXX Is this still needed?
            if tp == 7:  # User control
                h.as_Control().ShowControl()
            self._itemlist_shown.append(item)

    def _hideitemlist(self, itemlist):
        """Make items in itemlist inactive and invisible. NOTE: obsolete"""
        for item in itemlist:
            if item not in self._itemlist_shown:
                continue
            self._dialog.HideDialogItem(item)
            tp, h, rect = self._dialog.GetDialogItem(item)
            if tp == 7:  # User control
                h.as_Control().HideControl()
            self._itemlist_shown.remove(item)

    def _showitemcontrols(self, itemlist):
        """Make sure item controls (plus any control embedded) are visible and active"""
        for item in itemlist:
            ##             if item in self._itemlist_shown:
            ##                 continue
            ctl = self._dialog.GetDialogItemAsControl(item)
            ctl.ShowControl()
##             self._itemlist_shown.append(item)

    def _hideitemcontrols(self, itemlist):
        """Make item controls (plus anything embedded) are invisible"""
        for item in itemlist:
            ##             if item not in self._itemlist_shown:
            ##                 continue
            ctl = self._dialog.GetDialogItemAsControl(item)
            ctl.HideControl()


##             self._itemlist_shown.remove(item)

    def _setsensitive(self, itemlist, sensitive):
        """Set or reset item sensitivity to user input"""
        for item in itemlist:
            ctl = self._dialog.GetDialogItemAsControl(item)
            if sensitive:
                ctl.ActivateControl()
            else:
                ctl.DeactivateControl()
        if sensitive:
            self._showitemlist(itemlist)

    def _setctlvisible(self, itemlist, visible):
        """Set or reset item visibility"""
        for item in itemlist:
            ctl = self._dialog.GetDialogItemAsControl(item)
            if visible:
                ctl.ShowControl()
            else:
                ctl.HideControl()

    def _settextsensitive(self, itemlist, sensitive):
        """Set or reset item sensitivity to user input"""
        for item in itemlist:
            tp, h, rect = self._dialog.GetDialogItem(
                item)  # XXXX How to handle this?
            if sensitive:
                tp = tp & ~128
            else:
                tp = tp | 128
            self._dialog.SetDialogItem(item, tp, h, rect)
        if sensitive:
            self._showitemlist(itemlist)

    def _setlabel(self, item, text):
        """Set the text of a static text or edit text"""
        text = _string2dialog(text)
        ##         print 'DBG: setlabel', item, text
        h = self._dialog.GetDialogItemAsControl(item)
        Dlg.SetDialogItemText(h, text)

    def _getlabel(self, item):
        """Return the text of a static text or edit text"""
        h = self._dialog.GetDialogItemAsControl(item)
        text = Dlg.GetDialogItemText(h)
        if '\r' in text:
            text = string.split(text, '\r')
            text = string.join(text, '\n')
        return text

    def _settitle(self, item, text):
        """Set the title of a control item"""
        text = _string2dialog(text)
        ctl = self._dialog.GetDialogItemAsControl(item)
        ctl.SetControlTitle(text)

    def _selectinputfield(self, item):
        """Select all text in an input field"""
        self._dialog.SelectDialogItemText(item, 0, 32767)

    def _setbutton(self, item, value):
        ctl = self._dialog.GetDialogItemAsControl(item)
        ctl.SetControlValue(value)

    def _getbutton(self, item):
        ctl = self._dialog.GetDialogItemAsControl(item)
        return ctl.GetControlValue()

    def _togglebutton(self, item):
        ctl = self._dialog.GetDialogItemAsControl(item)
        value = ctl.GetControlValue()
        ctl.SetControlValue(not value)

    def close(self):
        """Close the dialog and free resources."""
        self._window.close()
        self._dialog = None

    def show(self):
        """Show the dialog."""
        self._window.show(geometry=self.last_geometry)
        self._window.pop()
        self._window.register(WMEVENTS.WindowExit, self.goaway, ())

    def pop(self):
        """Pop window to front"""
        self._window.pop()

    def goaway(self, *args):
        """Callback used when user presses go-away box of window"""
        self.hide()

    def hide(self):
        """Hide the dialog."""
        self._window.hide()

    def rungrabbed(self):
        self._window.rungrabbed()

    def settitle(self, title):
        """Set (change) the title of the window.

        Arguments (no defaults):
        title -- string to be displayed as new window title.
        """
        self._window.settitle(title)

    def is_showing(self):
        """Return whether dialog is showing."""
        return self._window.is_showing()

    def setcursor(self, cursor):
        """Set the cursor to a named shape.

        Arguments (no defaults):
        cursor -- string giving the name of the desired cursor shape
        """
        self._window.setcursor(cursor)