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


Python Color.colorHex方法代码示例

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


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

示例1: Tray

# 需要导入模块: from Color import Color [as 别名]
# 或者: from Color.Color import colorHex [as 别名]
class Tray():
    def __init__(self, display):
        self.display = display

        self.screen = self.display.screen()

        self.Color = Color(self.screen.default_colormap)

        backgroundColor = self.Color.colorHex(Solarized.base03)

        self.window = self.screen.root.create_window(
            0, 0, Util.getScreenWidth(display), 20, 1,
            self.screen.root_depth,
            background_pixel = backgroundColor,
            event_mask=X.ExposureMask | X.KeyPressMask | X.ButtonPressMask 
            )
 
        fontPattern = "-*-DejaVu Sans mono-medium-r-*-*-14-*-*-*-*-*-*-*"
        #print self.display.list_fonts(fontPattern, 1)

        self.textGC = self.window.create_gc(
            foreground = self.Color.colorHex(Solarized.base2),
            background = backgroundColor,
            font = self.display.open_font(fontPattern)
            )

        self.activeGC = self.window.create_gc(
            foreground = self.Color.colorHex(Solarized.base01),
            background = backgroundColor
            )

        self.inuseGC = self.window.create_gc(
            foreground = self.Color.colorHex(Solarized.base3),
            background = backgroundColor
            )
 
        self.window.map()

        self.cmdMode = False
        self.text = ''


    def enterCmdMode(self):
        self.window.set_input_focus(X.RevertToParent, X.CurrentTime)
        self.window.configure(stack_mode = X.Above)
        self.cmdMode = True
        self.redraw()

    def exitCmdMode(self):
        self.screen.root.set_input_focus(X.RevertToParent, X.CurrentTime)
        self.cmdMode = False
        self.redraw()

    def processEvent(self, event):
        if event.type == X.Expose:
            self.expose(event)
        if event.type == X.KeyPress:
            key = Util.getSym(self.display, event.detail, event.state)
            self.keypress(key)
        elif event.type == X.ButtonPressMask:
            self.mousepress(event.detail, event.event_x, event.event_y, event.state)

    def expose(self, event):
        self.redraw()

    def keypress(self, key):
        if self.cmdMode:
            if key > 0 and key < 256:
                self.text += chr(key)
            elif key == XK_BackSpace:
                self.text = self.text[:-1]
            elif key == XK_Return:
                bash.run(self.text)
                self.text = ''
                self.exitCmdMode()
            elif key == XK_Escape:
                self.text = ''
                self.exitCmdMode()
            
            self.redraw()

    def mousepress(self, button, x, y, state):
        print button, x, y, state

    def setRoots(self, roots):
        self.roots = roots
        self.redraw()
    
    def redraw(self):
        self.window.clear_area()
        i = 1
        for root in self.roots:
            if root.active:
                self.window.fill_rectangle(self.activeGC, (i-1)*16, 0, 16, 20)
            if len(root.frames) > 0:
                self.window.fill_rectangle(self.inuseGC, (i-1)*16 + 2, 2, 4, 4)
            self.window.draw_text(self.textGC, 3 + (i-1)*16, 14, str(i))
            i += 1
        if self.cmdMode:
            self.window.draw_text(self.textGC, i*16, 14, 'run: ' + self.text)
开发者ID:es92,项目名称:strwm,代码行数:102,代码来源:Tray.py


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