def __init__(self, widget, palette=(), screen=None, handle_mouse=True, input_filter=None, unhandled_input=None, event_loop=None, pop_ups=False): self._widget = widget self.handle_mouse = handle_mouse self.pop_ups = pop_ups # triggers property setting side-effect if not screen: from urwid import raw_display screen = raw_display.Screen() if palette: screen.register_palette(palette) self.screen = screen self.screen_size = None self._unhandled_input = unhandled_input self._input_filter = input_filter if not hasattr(screen, 'hook_event_loop') and event_loop is not None: raise NotImplementedError( "screen object passed " "%r does not support external event loops" % (screen, )) if event_loop is None: event_loop = SelectEventLoop() self.event_loop = event_loop self._watch_pipes = {}
def __init__(self): """This the TabManager Class""" self.lookupRooms = [[None, None, 0]] self.sortTabs = False self.ShownRoom = None self.name, self.version = "", "" self.tui = raw_display.Screen() self.tui.set_input_timeouts(0.1)
def __init__(self, widget, palette=[], screen=None, handle_mouse=True, input_filter=None, unhandled_input=None, event_loop=None, pop_ups=False): """ Simple main loop implementation. widget -- topmost widget used for painting the screen, stored as self.widget and may be modified palette -- initial palette for screen screen -- screen object or None to use raw_display.Screen, stored as self.screen handle_mouse -- True to process mouse events, passed to self.screen input_filter -- a function to filter input before sending it to self.widget, called from self.input_filter unhandled_input -- a function called when input is not handled by self.widget, called from self.unhandled_input event_loop -- if screen supports external an event loop it may be given here, or leave as None to use SelectEventLoop, stored as self.event_loop pop_ups -- True to wrap self.widget with a PopUpTarget instance to allow any widget to open a pop-up anywhere on the screen This is the standard main loop implementation with a single screen. The widget passed must be a box widget. """ self._widget = widget self.handle_mouse = handle_mouse self.pop_ups = pop_ups # triggers property setting side-effect if not screen: from urwid import raw_display screen = raw_display.Screen() if palette: screen.register_palette(palette) self.screen = screen self.screen_size = None self._unhandled_input = unhandled_input self._input_filter = input_filter if not hasattr(screen, 'get_input_descriptors' ) and event_loop is not None: raise NotImplementedError("screen object passed " "%r does not support external event loops" % (screen,)) if event_loop is None: event_loop = SelectEventLoop() self.event_loop = event_loop self._input_timeout = None self._watch_pipes = {}
def __init__(self, controller, style): # Shared objects to help event handling. self.events = Queue() self.lock = Lock() self.view = MainWindow(controller) self.screen = raw_display.Screen() self.screen.set_terminal_properties(256) self.loop = MainLoop(widget=self.view, palette=style, screen=self.screen, unhandled_input=Tui.exit_handler, pop_ups=True) self.pipe = self.loop.watch_pipe(self.update_ui) self.loop.set_alarm_in(0.1, self.update_timer, self.view.logo.timer) connect_signal(self.view.issues_table, 'refresh', lambda source: self.loop.draw_screen()) connect_signal(self.view.stat_table, 'refresh', lambda source: self.loop.draw_screen())
# -*- coding: UTF-8 import urwid from urwid import raw_display import leftBox import mbox screenCols, screenRows = raw_display.Screen().get_cols_rows() class WechatMain(object): def __init__(self, palette): self.chatButton = urwid.Button("chat") self.contactButton = urwid.Button("contact") self.sendButton = urwid.Button("send") self.inputBox = urwid.Edit(multiline=True) self.current_chat_from = "" self.owner_id = "" self.palette = palette self.loop = None def initUserInfo(self, owner_id, owner_name, on_contact_item_click, on_chat_item_click, contactlist=[], chatlist=[]): self.owner_id = owner_id self.owner_name = owner_name self.messageListBox = mbox.MessageListBox(self.owner_id) self.chatListBox = leftBox.ChatListBox(owner_id, on_contact_item_click,
# The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. import random import urwid from urwid import raw_display cols, rows = raw_display.Screen().get_cols_rows() palette = [('matrix', 'light green', 'black'), ('matrix-new', 'white', 'black')] class MatrixColumnWidget(urwid.Pile): signals = ['started'] def __init__(self): self.mrows = [urwid.Text(' ') for x in range(rows)] self.__super.__init__(self.mrows) self.l = 0 self.r = 0 self.more = 0
#!/usr/bin/python # coding=utf-8 from urwid import raw_display s = raw_display.Screen() def get_screen_cols(): cols, rows = s.get_cols_rows() return cols def get_screen_rows(): cols, rows = s.get_cols_rows() return rows