当前位置: 首页>>代码示例>>Python>>正文


Python urwid.Widget方法代码示例

本文整理汇总了Python中urwid.Widget方法的典型用法代码示例。如果您正苦于以下问题:Python urwid.Widget方法的具体用法?Python urwid.Widget怎么用?Python urwid.Widget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在urwid的用法示例。


在下文中一共展示了urwid.Widget方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Widget [as 别名]
def __init__(self):
        def selectButton(radio_button, new_state, parameter):
            if new_state:
                closeOverlay()
                self._select(parameter)

        super().__init__(urwid.SimpleFocusListWalker([]))
        buttons = []
        for i, item in enumerate(self._items()):
            if isinstance(item, urwid.Widget):
                self.body.append(item)
                continue
            elif isinstance(item, tuple):
                name, selected, parameter = item
            else:
                parameter = name = item
                selected = False
            self.body.append(urwid.RadioButton(buttons, name, selected,
                                               selectButton, parameter))
            if selected:
                self.set_focus(i) 
开发者ID:ids1024,项目名称:wikicurses,代码行数:23,代码来源:main.py

示例2: test1

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Widget [as 别名]
def test1(self):
        a = urwid.Text("")
        b = urwid.Text("")
        blah = urwid.TextCanvas()
        blah.finalize(a, (10,1), False)
        blah2 = urwid.TextCanvas()
        blah2.finalize(a, (15,1), False)
        bloo = urwid.TextCanvas()
        bloo.finalize(b, (20,2), True)

        urwid.CanvasCache.store(urwid.Widget, blah)
        urwid.CanvasCache.store(urwid.Widget, blah2)
        urwid.CanvasCache.store(urwid.Widget, bloo)

        self.cct(a, (10,1), False, blah)
        self.cct(a, (15,1), False, blah2)
        self.cct(a, (15,1), True, None)
        self.cct(a, (10,2), False, None)
        self.cct(b, (20,2), True, bloo)
        self.cct(b, (21,2), True, None)
        urwid.CanvasCache.invalidate(a)
        self.cct(a, (10,1), False, None)
        self.cct(a, (15,1), False, None)
        self.cct(b, (20,2), True, bloo) 
开发者ID:AnyMesh,项目名称:anyMesh-Python,代码行数:26,代码来源:test_canvas.py

示例3: _createAlertLevelsWidgetList

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Widget [as 别名]
def _createAlertLevelsWidgetList(self, alertLevels: List[AlertLevel]) -> List[urwid.Widget]:

        temp = list()
        first = True
        for alertLevel in alertLevels:

            if first:
                first = False
            else:
                temp.append(urwid.Divider())
                temp.append(urwid.Divider("-"))

            temp.extend(self._createAlertLevelWidgetList(alertLevel))

        return temp

    # this function creates the detailed output of a alert level object
    # in a list 
开发者ID:sqall01,项目名称:alertR,代码行数:20,代码来源:screenElements.py

示例4: _createAlertWidgetList

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Widget [as 别名]
def _createAlertWidgetList(self, alert: Alert) -> List[urwid.Widget]:

        temp = list()

        temp.append(urwid.Text("Alert ID:"))
        temp.append(urwid.Text(str(alert.alertId)))
        temp.append(urwid.Divider())

        temp.append(urwid.Text("Remote Alert ID:"))
        temp.append(urwid.Text(str(alert.remoteAlertId)))
        temp.append(urwid.Divider())

        temp.append(urwid.Text("Description:"))
        temp.append(urwid.Text(alert.description))

        return temp

    # this function creates the detailed output of a node object
    # in a list 
开发者ID:sqall01,项目名称:alertR,代码行数:21,代码来源:screenElements.py

示例5: _createSensorsWidgetList

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Widget [as 别名]
def _createSensorsWidgetList(self, sensors: List[Sensor]) -> List[urwid.Widget]:

        temp = list()
        first = True
        for sensor in sensors:

            if first:
                first = False
            else:
                temp.append(urwid.Divider())
                temp.append(urwid.Divider("-"))

            temp.extend(self._createSensorWidgetList(sensor))

        return temp

    # this function creates the detailed output of a sensor object
    # in a list 
开发者ID:sqall01,项目名称:alertR,代码行数:20,代码来源:screenElements.py

示例6: __init__

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Widget [as 别名]
def __init__(self, *contents, tabbar=None):
        """
        Create new Tabs widget

        contents: Iterable of dictionaries or iterables that match the arguments
                  of the `insert` method
        tabbar: TabBar instance that is used to display tab titles or any object
                with a 'base_widget' attribute (e.g. AttrMap) that returns a
                TabBar object
        """
        if tabbar is None:
            self._tabbar = TabBar()
        elif not isinstance(tabbar, urwid.Widget):
            raise ValueError('tabbar must be TabBar instance, not {}: {!r}'
                             .format(type(tabbar).__name__, tabbar))
        else:
            self._tabbar = tabbar

        self._ids = []
        self._focus_history = []
        self._info = defaultdict(lambda: {})
        self._contents = urwid.MonitoredFocusList()
        self._contents.set_focus_changed_callback(self._focus_changed_callback)
        for content in contents:
            if not isinstance(content, abc.Mapping):
                content = dict(zip(('title', 'widget', 'position', 'focus'),
                                   content))
            self.insert(**content) 
开发者ID:rndusr,项目名称:stig,代码行数:30,代码来源:tabs.py

示例7: insert

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Widget [as 别名]
def insert(self, title, widget=None, position=-1, focus=True):
        """
        Insert new tab

        title: Any flow or fixed widget to use as the tab's title
        widget: Widget to show when this tab is selected or None
        position: Where to insert the new tab; int for list-like index or
                  'right'/'left' to insert next to focused tab
        focus: True to focus the new tab, False otherwise

        Return TabID of inserted tab
        """
        curpos = self.focus_position
        if position == 'right':
            newpos = (curpos + 1) if curpos is not None else 0
        elif position == 'left':
            newpos = max(curpos, 0) if curpos is not None else 0
        elif isinstance(position, int):
            if position < 0:
                newpos = position + len(self._contents) + 1
            else:
                newpos = position
        else:
            raise ValueError('Invalid position: {!r}'.format(position))

        # Insert new tab ID
        this_id = _find_unused_id(self._ids)
        self._ids.insert(newpos, this_id)

        # Insert title
        self._tabbar.base_widget.insert(newpos, title)

        # Insert content
        self._contents.insert(newpos, widget)
        if focus:
            self.focus_position = newpos
        return this_id 
开发者ID:rndusr,项目名称:stig,代码行数:39,代码来源:tabs.py

示例8: cct

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Widget [as 别名]
def cct(self, widget, size, focus, expected):
        got = urwid.CanvasCache.fetch(widget, urwid.Widget, size, focus)
        assert expected==got, "got: %s expected: %s"%(got, expected) 
开发者ID:AnyMesh,项目名称:anyMesh-Python,代码行数:5,代码来源:test_canvas.py

示例9: _createAlertLevelWidgetList

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Widget [as 别名]
def _createAlertLevelWidgetList(self, alertLevel: AlertLevel) -> List[urwid.Widget]:

        temp = list()

        temp.append(urwid.Text("Alert Level:"))
        temp.append(urwid.Text(str(alertLevel.level)))
        temp.append(urwid.Divider())

        temp.append(urwid.Text("Name:"))
        temp.append(urwid.Text(alertLevel.name))
        temp.append(urwid.Divider())

        temp.append(urwid.Text("Trigger Always:"))
        if alertLevel.triggerAlways == 0:
            temp.append(urwid.Text("No"))
        elif alertLevel.triggerAlways == 1:
            temp.append(urwid.Text("Yes"))
        else:
            temp.append(urwid.Text("Undefined"))
        temp.append(urwid.Divider())

        temp.append(urwid.Text("Rules Activated:"))
        if alertLevel.rulesActivated == 0:
            temp.append(urwid.Text("No"))
        elif alertLevel.rulesActivated == 1:
            temp.append(urwid.Text("Yes"))
        else:
            temp.append(urwid.Text("Undefined"))

        return temp

    # this function creates the detailed output of a node object
    # in a list 
开发者ID:sqall01,项目名称:alertR,代码行数:35,代码来源:screenElements.py

示例10: _createManagerWidgetList

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Widget [as 别名]
def _createManagerWidgetList(self, manager: Manager) -> List[urwid.Widget]:

        temp = list()

        temp.append(urwid.Text("Manager ID:"))
        temp.append(urwid.Text(str(manager.managerId)))
        temp.append(urwid.Divider())

        temp.append(urwid.Text("Description:"))
        temp.append(urwid.Text(manager.description))

        return temp

    # this function creates the detailed output of a node object
    # in a list 
开发者ID:sqall01,项目名称:alertR,代码行数:17,代码来源:screenElements.py

示例11: __init__

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Widget [as 别名]
def __init__(self, keybindings):
        self._widgets = []  # [urwid.Widget]
        self._widget_title = {}  # {urwid.Widget: str}
        self._tab_index = None  # int
        self._keys = keybindings
        self._tabs = urwid.Text('')
        self._frame = urwid.Frame(None)
        super().__init__(urwid.Pile([
            ('pack', urwid.AttrMap(self._tabs, 'tab_background')),
            ('weight', 1, self._frame),
        ])) 
开发者ID:tdryer,项目名称:hangups,代码行数:13,代码来源:__main__.py

示例12: _createNodeWidgetList

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Widget [as 别名]
def _createNodeWidgetList(self, node: Node) -> List[urwid.Widget]:

        temp = list()

        temp.append(urwid.Text("Node ID:"))
        temp.append(urwid.Text(str(node.nodeId)))
        temp.append(urwid.Divider())

        temp.append(urwid.Text("Username:"))
        temp.append(urwid.Text(node.username))
        temp.append(urwid.Divider())

        temp.append(urwid.Text("Hostname:"))
        temp.append(urwid.Text(node.hostname))
        temp.append(urwid.Divider())

        temp.append(urwid.Text("Node Type:"))
        temp.append(urwid.Text(node.nodeType))
        temp.append(urwid.Divider())

        temp.append(urwid.Text("Instance:"))
        temp.append(urwid.Text(node.instance))
        temp.append(urwid.Divider())

        temp.append(urwid.Text("Version:"))
        versionWidget = urwid.Text(str(node.version) + "-" + str(node.rev))
        temp.append(versionWidget)
        temp.append(urwid.Divider())

        temp.append(urwid.Text("Connected:"))
        if node.connected == 0:
            temp.append(urwid.AttrMap(urwid.Text("False"), "disconnected"))
        elif node.connected == 1:
            temp.append(urwid.AttrMap(urwid.Text("True"), "neutral"))
        else:
            temp.append(urwid.AttrMap(urwid.Text("Undefined"), "redColor"))
        temp.append(urwid.Divider())

        temp.append(urwid.Text("Persistent Connection:"))
        if node.persistent == 0:
            temp.append(urwid.Text("False"))
        elif node.persistent == 1:
            if node.connected == 0:
                temp.append(urwid.AttrMap(urwid.Text("True"), "disconnected"))
            else:
                temp.append(urwid.Text("True"))
        else:
            temp.append(urwid.AttrMap(urwid.Text("Undefined"), "redColor"))

        return temp

    # this function creates the detailed output of a sensor object
    # in a list 
开发者ID:sqall01,项目名称:alertR,代码行数:55,代码来源:screenElements.py

示例13: _createSensorWidgetList

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Widget [as 别名]
def _createSensorWidgetList(self, sensor: Sensor) -> List[urwid.Widget]:

        temp = list()

        temp.append(urwid.Text("Sensor ID:"))
        temp.append(urwid.Text(str(sensor.sensorId)))
        temp.append(urwid.Divider())

        temp.append(urwid.Text("Remote Sensor ID:"))
        temp.append(urwid.Text(str(sensor.remoteSensorId)))
        temp.append(urwid.Divider())

        temp.append(urwid.Text("Alert Delay:"))
        temp.append(urwid.Text(str(sensor.alertDelay) + " Seconds"))
        temp.append(urwid.Divider())

        temp.append(urwid.Text("Description:"))
        temp.append(urwid.Text(sensor.description))
        temp.append(urwid.Divider())

        temp.append(urwid.Text("State:"))
        if sensor.state == 0:
            temp.append(urwid.AttrMap(urwid.Text("Normal"), "neutral"))
        elif sensor.state == 1:
            temp.append(urwid.AttrMap(urwid.Text("Triggered"), "sensoralert"))
        else:
            temp.append(urwid.AttrMap(urwid.Text("Undefined"), "redColor"))
        temp.append(urwid.Divider())

        temp.append(urwid.Text("Data Type:"))
        if sensor.dataType == SensorDataType.NONE:
            temp.append(urwid.Text("None"))
        elif sensor.dataType == SensorDataType.INT:
            temp.append(urwid.Text("Integer"))
        elif sensor.dataType == SensorDataType.FLOAT:
            temp.append(urwid.Text("Floating Point"))
        else:
            temp.append(urwid.Text("Unknown"))
        temp.append(urwid.Divider())

        temp.append(urwid.Text("Data:"))
        if sensor.dataType == SensorDataType.NONE:
            temp.append(urwid.Text("None"))
        else:
            temp.append(urwid.Text(str(sensor.data)))
        temp.append(urwid.Divider())

        temp.append(urwid.Text("Last Updated (Server Time):"))
        lastUpdatedWidget = urwid.Text(time.strftime("%D %H:%M:%S", time.localtime(sensor.lastStateUpdated)))
        temp.append(lastUpdatedWidget)

        return temp

    # this function returns the final urwid widget that is used
    # to render this object 
开发者ID:sqall01,项目名称:alertR,代码行数:57,代码来源:screenElements.py


注:本文中的urwid.Widget方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。