Python wx.WANTS_CHARS Examples

The following are 13 code examples of wx.WANTS_CHARS(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module wx , or try the search function .
Example #1
Source File: trelby.py    From trelby with GNU General Public License v2.0 7 votes vote down vote up
def __init__(self, parent, id):
        style = wx.WANTS_CHARS | wx.FULL_REPAINT_ON_RESIZE | wx.NO_BORDER
        wx.Control.__init__(self, parent, id, style = style)

        self.panel = parent

        wx.EVT_SIZE(self, self.OnSize)
        wx.EVT_PAINT(self, self.OnPaint)
        wx.EVT_ERASE_BACKGROUND(self, self.OnEraseBackground)
        wx.EVT_LEFT_DOWN(self, self.OnLeftDown)
        wx.EVT_LEFT_UP(self, self.OnLeftUp)
        wx.EVT_LEFT_DCLICK(self, self.OnLeftDown)
        wx.EVT_RIGHT_DOWN(self, self.OnRightDown)
        wx.EVT_MOTION(self, self.OnMotion)
        wx.EVT_MOUSEWHEEL(self, self.OnMouseWheel)
        wx.EVT_CHAR(self, self.OnKeyChar)

        self.createEmptySp()
        self.updateScreen(redraw = False) 
Example #2
Source File: trelby.py    From trelby with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, parent, id):
        wx.Panel.__init__(
            self, parent, id,
            # wxMSW/Windows does not seem to support
            # wx.NO_BORDER, which sucks
            style = wx.WANTS_CHARS | wx.NO_BORDER)

        hsizer = wx.BoxSizer(wx.HORIZONTAL)

        self.scrollBar = wx.ScrollBar(self, -1, style = wx.SB_VERTICAL)
        self.ctrl = MyCtrl(self, -1)

        hsizer.Add(self.ctrl, 1, wx.EXPAND)
        hsizer.Add(self.scrollBar, 0, wx.EXPAND)

        wx.EVT_COMMAND_SCROLL(self, self.scrollBar.GetId(),
                              self.ctrl.OnScroll)

        wx.EVT_SET_FOCUS(self.scrollBar, self.OnScrollbarFocus)

        self.SetSizer(hsizer)

    # we never want the scrollbar to get the keyboard focus, pass it on to
    # the main widget 
Example #3
Source File: MakeTorrent.py    From BitTorrent with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent, nodelist):
        Grid.__init__(self, parent, style=wx.WANTS_CHARS)

        self.CreateGrid( 0, 2, wx.grid.Grid.SelectRows)
        self.SetColLabelValue(0, _("Host"))
        self.SetColLabelValue(1, _("Port"))

        self.SetColRenderer(1, wx.grid.GridCellNumberRenderer())
        self.SetColEditor(1, wx.grid.GridCellNumberEditor(0, 65535))

        self.SetColLabelSize(self.GetTextExtent("l")[1]+4)
        self.SetRowLabelSize(1)
        self.SetSize((1000,1000))

        self.storing = False
        self.Bind(wx.grid.EVT_GRID_CMD_CELL_CHANGE, self.store_value)

        self.append_node(('router.bittorrent.com', '65536'))

        for i, e in enumerate(nodelist.split(',')):
            host, port = e.split(':')
            self.append_node((host,port))

        self.append_node(('','')) 
Example #4
Source File: menubar.py    From wxGlade with MIT License 6 votes vote down vote up
def __init__(self, parent, owner, items=None):
        style = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.WANTS_CHARS
        wx.Dialog.__init__(self, parent, -1, _("Menu editor"), style=style)

        self.create_gui()
        self.bind_event_handlers()
        self._set_tooltips()
        self.owner = owner

        import re
        self.handler_re = self.name_re = re.compile(r'^[a-zA-Z_]+[\w-]*(\[\w*\])*$')

        self.selected_index = -1  # index of the selected element in the wx.ListCtrl menu_items
        self._ignore_events = False

        if items:
            self.add_items(items)
            self._select_item(0)
        else:
            self._enable_fields(False) 
Example #5
Source File: toolbar.py    From wxGlade with MIT License 6 votes vote down vote up
def __init__(self, parent, owner, items=None):
        style = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.WANTS_CHARS
        wx.Dialog.__init__(self, parent, -1, _("Toolbar editor"), style=style)

        self.create_gui()
        self.bind_event_handlers()
        self._set_tooltips()
        self.owner = owner

        self.handler_re = self.name_re = re.compile(r'^[a-zA-Z_]+[\w-]*(\[\w*\])*$')

        self.selected_index = -1  # index of the selected element in the wx.ListCtrl menu_items
        self._ignore_events = False

        if items:
            self.add_items(items)
            self._select_item(0)
        else:
            self._enable_fields(False) 
Example #6
Source File: misc.py    From trelby with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, parent, text, title, validateFunc = None):
        wx.Dialog.__init__(self, parent, -1, title,
                           style = wx.DEFAULT_DIALOG_STYLE | wx.WANTS_CHARS)

        # function to call to validate the input string on OK. can be
        # None, in which case it is not called. if it returns "", the
        # input is valid, otherwise the string it returns is displayed in
        # a message box and the dialog is not closed.
        self.validateFunc = validateFunc

        vsizer = wx.BoxSizer(wx.VERTICAL)

        vsizer.Add(wx.StaticText(self, -1, text), 1, wx.EXPAND | wx.BOTTOM, 5)

        self.tc = wx.TextCtrl(self, -1, style = wx.TE_PROCESS_ENTER)
        vsizer.Add(self.tc, 1, wx.EXPAND);

        vsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)

        hsizer = wx.BoxSizer(wx.HORIZONTAL)

        cancelBtn = gutil.createStockButton(self, "Cancel")
        hsizer.Add(cancelBtn)

        okBtn = gutil.createStockButton(self, "OK")
        hsizer.Add(okBtn, 0, wx.LEFT, 10)

        vsizer.Add(hsizer, 0, wx.EXPAND | wx.TOP, 5)

        util.finishWindow(self, vsizer)

        wx.EVT_BUTTON(self, cancelBtn.GetId(), self.OnCancel)
        wx.EVT_BUTTON(self, okBtn.GetId(), self.OnOK)

        wx.EVT_TEXT_ENTER(self, self.tc.GetId(), self.OnOK)

        wx.EVT_CHAR(self.tc, self.OnCharEntry)
        wx.EVT_CHAR(cancelBtn, self.OnCharButton)
        wx.EVT_CHAR(okBtn, self.OnCharButton)

        self.tc.SetFocus() 
Example #7
Source File: misc.py    From trelby with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, parent, id, size):
        wx.Window.__init__(self, parent, id, size = size,
                           style = wx.WANTS_CHARS)

        wx.EVT_CHAR(self, self.OnKeyChar) 
Example #8
Source File: DownloadManager.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, torrent, parent, *a, **k):
        self.torrent = torrent
        k['style'] = k.get('style', wx.DEFAULT_FRAME_STYLE) | wx.WANTS_CHARS
        BTFrameWithSizer.__init__(self, parent, *a, **k)
        self.Bind(wx.EVT_CLOSE, self.close)
        self.Bind(wx.EVT_CHAR, self.key)
        self.panel.BindChildren(wx.EVT_CHAR, self.key)
        if sys.platform == 'darwin':
            self.sizer.AddSpacer((0, 14))
        self.sizer.Layout()
        self.Fit()
        self.SetMinSize(self.GetSize()) 
Example #9
Source File: SettingsWindow.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, main_window, config, setfunc):
        BTDialog.__init__(self, main_window, style=wx.DEFAULT_DIALOG_STYLE|wx.CLIP_CHILDREN|wx.WANTS_CHARS)
        self.Bind(wx.EVT_CLOSE, self.close)
        self.Bind(wx.EVT_CHAR, self.key)
        self.SetTitle(_("%s Settings")%app_name)

        self.setfunc = setfunc
        self.config = config

        self.notebook = wx.Notebook(self)

        self.notebook.Bind(wx.EVT_CHAR, self.key)

        self.general_panel    =    GeneralSettingsPanel(self.notebook)
        self.saving_panel     =     SavingSettingsPanel(self.notebook)
        self.network_panel    =    NetworkSettingsPanel(self.notebook)
        self.appearance_panel = AppearanceSettingsPanel(self.notebook)
        self.language_panel   =   LanguageSettingsPanel(self.notebook)

        self.vbox = VSizer()
        self.vbox.AddFirst(self.notebook, proportion=1, flag=wx.GROW)

        self.vbox.Layout()

        self.SetSizerAndFit(self.vbox)
        self.SetFocus() 
Example #10
Source File: CellEditor.py    From bookhub with MIT License 5 votes vote down vote up
def _MakeDateEditor(olv, rowIndex, subItemIndex):
        dte =  DateEditor(olv, style=wx.DP_DROPDOWN | wx.DP_SHOWCENTURY | wx.WANTS_CHARS)
        #dte.SetValidator(MyValidator(olv))
        return dte 
Example #11
Source File: CardAndReaderTreePanel.py    From pyscard with GNU Lesser General Public License v2.1 4 votes vote down vote up
def __init__(self, parent, appstyle, clientpanel):
        """Constructor. Create a smartcard and reader tree control on the
        left-hand side of the application main frame.
        @param parent: the tree panel parent
        @param appstyle: a combination of the following styles (bitwise or |)
          - TR_SMARTCARD: display a smartcard tree panel
          - TR_READER: display a reader tree panel
          - default is TR_DEFAULT = TR_SMARTCARD
        @param clientpanel: the client panel to notify of smartcard and reader events
        """
        wx.Panel.__init__(self, parent, -1, style=wx.WANTS_CHARS)

        sizer = wx.BoxSizer(wx.VERTICAL)

        # create the smartcard tree
        if appstyle & smartcard.wx.SimpleSCardApp.TR_SMARTCARD:
            self.cardtreectrl = CardTreeCtrl(self, clientpanel=clientpanel)

            # create the smartcard insertion observer
            self.cardtreecardobserver = self._CardObserver(self.cardtreectrl)

            # register as a CardObserver; we will ge
            # notified of added/removed cards
            self.cardmonitor = CardMonitor()
            self.cardmonitor.addObserver(self.cardtreecardobserver)

            sizer.Add(
                self.cardtreectrl, flag=wx.EXPAND | wx.ALL, proportion=1)

        # create the reader tree
        if appstyle & smartcard.wx.SimpleSCardApp.TR_READER:
            self.readertreectrl = ReaderTreeCtrl(
                                        self, clientpanel=clientpanel)

            # create the reader insertion observer
            self.readertreereaderobserver = self._ReaderObserver(
                                                    self.readertreectrl)

            # register as a ReaderObserver; we will ge
            # notified of added/removed readers
            self.readermonitor = ReaderMonitor()
            self.readermonitor.addObserver(self.readertreereaderobserver)

            # create the smartcard insertion observer
            self.readertreecardobserver = self._CardObserver(
                                                self.readertreectrl)

            # register as a CardObserver; we will get
            # notified of added/removed cards
            self.cardmonitor = CardMonitor()
            self.cardmonitor.addObserver(self.readertreecardobserver)

            sizer.Add(
                self.readertreectrl, flag=wx.EXPAND | wx.ALL, proportion=1)

        self.SetSizer(sizer)
        self.SetAutoLayout(True) 
Example #12
Source File: wxcef.py    From Librian with Mozilla Public License 2.0 4 votes vote down vote up
def __init__(self, url, icon, title, size):
        self.browser = None

        # Must ignore X11 errors like 'BadWindow' and others by
        # installing X11 error handlers. This must be done after
        # wx was intialized.
        if LINUX:
            cef.WindowUtils.InstallX11ErrorHandlers()

        global g_count_windows
        g_count_windows += 1

        if WINDOWS:
            # noinspection PyUnresolvedReferences, PyArgumentList
            logging.debug("[wxpython.py] System DPI settings: %s"
                          % str(cef.DpiAware.GetSystemDpi()))
        if hasattr(wx, "GetDisplayPPI"):
            logging.debug("[wxpython.py] wx.GetDisplayPPI = %s" % wx.GetDisplayPPI())
        logging.debug("[wxpython.py] wx.GetDisplaySize = %s" % wx.GetDisplaySize())

        logging.debug("[wxpython.py] MainFrame DPI scaled size: %s" % str(size))

        wx.Frame.__init__(self, parent=None, id=wx.ID_ANY,
                          title=title)
        # wxPython will set a smaller size when it is bigger
        # than desktop size.
        logging.debug("[wxpython.py] MainFrame actual size: %s" % self.GetSize())

        ic = wx.Icon(icon, wx.BITMAP_TYPE_ICO)
        self.SetIcon(ic)

        self.Bind(wx.EVT_CLOSE, self.OnClose)

        # Set wx.WANTS_CHARS style for the keyboard to work.
        # This style also needs to be set for all parent controls.
        self.browser_panel = wx.Panel(self, size=tuple(size))
        self.browser_panel.Bind(wx.EVT_SIZE, self.OnSize)
        wx.Window.Fit(self)

        if MAC:
            # Make the content view for the window have a layer.
            # This will make all sub-views have layers. This is
            # necessary to ensure correct layer ordering of all
            # child views and their layers. This fixes Window
            # glitchiness during initial loading on Mac (Issue #371).
            NSApp.windows()[0].contentView().setWantsLayer_(True)

        if LINUX:
            self.Show()
            self.embed_browser(url)
        else:
            self.embed_browser(url)
            self.Show() 
Example #13
Source File: DownloadManager.py    From BitTorrent with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, main):
        BTDialog.__init__(self, main, size = (300,400),
                           style=wx.DEFAULT_DIALOG_STYLE|wx.CLIP_CHILDREN|wx.WANTS_CHARS)
        self.Bind(wx.EVT_CLOSE, self.close)
        self.SetTitle(_("About %s")%app_name)

        self.sizer = VSizer()

        i = wx.the_app.image_library.get(('logo', 'banner'))
        b = wx.BitmapFromImage(i)
        self.bitmap = ElectroStaticBitmap(self, b)

        self.sizer.AddFirst(self.bitmap, flag=wx.ALIGN_CENTER_HORIZONTAL)

        version_str = version
        if int(version_str[2]) % 2:
            version_str = version_str + ' ' + _("Beta")

        if '__WXGTK__' in wx.PlatformInfo:
            # wtf, "Version" forces a line break before the
            # version_str on WXGTK only -- most other strings work
            # fine.
            version_text = _("version %s") % version_str
        else:
            version_text = _("Version %s") % version_str
        version_label = ElectroStaticText(self, label=version_text)
        self.sizer.Add(version_label, flag=wx.ALIGN_CENTER_HORIZONTAL)

        if branch is not None:
            blabel = ElectroStaticText(self, label='working dir: %s' % branch)
            self.sizer.Add(blabel, flag=wx.ALIGN_CENTER_HORIZONTAL)


        self.credits_scroll = CreditsScroll(self, 'credits', style=wx.TE_CENTRE)
        self.lic_scroll = CreditsScroll(self, 'LICENSE', style=wx.TE_CENTRE)

        self.sizer.Add(self.lic_scroll, flag=wx.GROW, proportion=1)
        self.sizer.Add(self.credits_scroll, flag=wx.GROW, proportion=1)

        self.lic_scroll.Hide()

        self.button_sizer = HSizer()
        self.credits_button = wx.Button(parent=self, id=wx.ID_ANY, label=_("Li&cense"))
        self.credits_button.Bind(wx.EVT_BUTTON, self.toggle_credits)

        self.button_sizer.AddFirst(self.credits_button)

        self.sizer.Add(self.button_sizer, flag=wx.ALIGN_CENTER_HORIZONTAL, proportion=0, border=0)

        self.SetSizerAndFit(self.sizer)

        for w in (self, self.bitmap,
                  self.credits_scroll,
                  self.credits_button):
            w.Bind(wx.EVT_CHAR, self.key)

        self.SetFocus()