本文整理汇总了Python中label.Label类的典型用法代码示例。如果您正苦于以下问题:Python Label类的具体用法?Python Label怎么用?Python Label使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Label类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _draw_title
def _draw_title(self, gc, label=None, axis_offset=None):
""" Draws the title for the axis.
"""
if label is None:
title_label = Label(text=self.title,
font=self.title_font,
color=self.title_color,
rotate_angle=self.title_angle)
else:
title_label = label
# get the _rotated_ bounding box of the label
tl_bounds = array(title_label.get_bounding_box(gc), float64)
text_center_to_corner = -tl_bounds/2.0
# which axis are we moving away from the axis line along?
axis_index = self._major_axis.argmin()
if self.title_spacing != 'auto':
axis_offset = self.title_spacing
if (self.title_spacing) and (axis_offset is None ):
if not self.ticklabel_cache:
axis_offset = 25
else:
axis_offset = max([l._bounding_box[axis_index] for l in self.ticklabel_cache]) * 1.3
offset = (self._origin_point+self._end_axis_point)/2
axis_dist = self.tick_out + tl_bounds[axis_index]/2.0 + axis_offset
offset -= self._inside_vector * axis_dist
offset += text_center_to_corner
gc.translate_ctm(*offset)
title_label.draw(gc)
gc.translate_ctm(*(-offset))
return
示例2: activate
def activate(self):
''' Activate button. '''
Label.activate(self)
if self._action:
self._action(self)
Label.deactivate(self)
示例3: activate
def activate(self):
''' Activate button. '''
Label.activate(self)
if self._on_click:
self._on_click(self)
self.deactivate()
示例4: __init__
def __init__(self, text='Label', on_click=None):
''' Creates button. '''
Label.__init__(self, text)
self._focusable = True
self._activable = True
self._on_click = on_click
self.style = theme.Button
示例5: _update_value
def _update_value(self, dt):
value = self._getter()
if value != self._active:
self._active = value
if self._active:
Label.activate(self)
else:
Label.deactivate(self)
示例6: __init__
def __init__(self, text, link, enable_gaussian=True,
text_color=ui_theme.get_color("link_text")):
'''Init link button.'''
Label.__init__(self, text, text_color, enable_gaussian=enable_gaussian, text_size=9,
gaussian_radious=1, border_radious=0)
self.connect("button-press-event", lambda w, e: run_command("xdg-open %s" % link))
set_clickable_cursor(self)
示例7: test_load_from_db
def test_load_from_db(self):
label = Label()
label.load_from_db(1, self.connection)
self.assertEquals(label.id, 1)
self.assertEquals(label.day, "SUN, AM")
self.assertEquals(label.sermon_title, "Test Title")
self.assertEquals(label.minister, "H.L. Sheppard")
self.assertEquals(label.date, datetime.date(2014, 1, 1))
示例8: activate
def activate(self):
''' Activate toggle button. '''
Label.activate(self)
if not self._active:
self._active = True
else:
self._active = False
if self._on_click:
self._on_click(self)
Label.deactivate(self)
示例9: main
def main():
pygame.init()
screen = pygame.display.set_mode((200,200),16)
back = pygame.Surface(screen.get_size(),16)
##color = (238,238,230)
color = (255,255,255)
back.fill(color)
screen.blit(back,(0,0))
clock = pygame.time.Clock()
MyEvent = Event()
cb_images = []
cb_images.append(load_image(os.path.join('data'),'checkbox_off.png'))
cb_images.append(load_image(os.path.join('data'),'checkbox_on.png'))
b_images = []
b_images.append(load_image(os.path.join('data'),'button_off.png'))
b_images.append(load_image(os.path.join('data'),'button_on.png'))
checkbox = CheckBox('Check me',cb_images,(10,40))
button = Button('Click me',b_images,(10,80))
label = Label('Hola ...',(10,120))
textbox = TextField('',100,(10,160))
while 1:
btn = 0
key = 0
clock.tick(40)
for event in pygame.event.get():
if event.type == KEYDOWN:
if event.key == K_ESCAPE:
return
else:
key = event.key
elif event.type == MOUSEBUTTONDOWN:
btn = event.button
checkbox.notify(MyEvent, btn)
button.notify(MyEvent)
textbox.notify(MyEvent, key)
label.update(screen)
button.update(screen)
textbox.update(screen)
checkbox.update(screen)
pygame.display.flip()
示例10: fetch_mailboxes
def fetch_mailboxes(self):
response, mailbox_list = self.imap.list()
if response == 'OK':
for mailbox in mailbox_list:
mailbox_name = mailbox.split('"/"')[-1].replace('"', '').strip()
mailbox = Mailbox(self)
mailbox.external_name = mailbox_name
if mailbox_name.split('/')[0] !='[Gmail]':
label = Label(self)
label.label_tree = mailbox_name
self.labels[mailbox_name] = label
self.mailboxes[mailbox_name] = mailbox
示例11: __init__
def __init__(self, x, y, specialist_instance, selectable=False):
self.surface = Surface((200, 60))
self.specialist = specialist_instance
self.s_type = Label(0, 0, specialist.mapping[specialist_instance.s_type])
self.s_exp = Label(0, 40, "")
self.s_level = Label(0, 20, "")
self.selectable = selectable
self.selected = False
self.x = x
self.y = y
self.w = 200
self.h = 60
示例12: __init__
def __init__(self, text='Label', action=None):
'''
:Parameters:
`text` : str
Text to be displayed within button
`action` : function(button)
Action to be executed when button is toggled
'''
Label.__init__(self, text)
self._focusable = True
self._activable = True
self._action = action
self.style = theme.Button
示例13: handle_exception
def handle_exception(ex, stacktrace=None):
err_icon = os.path.join(os.path.dirname(__file__), 'graphics', 'icon_error.gif')
frm = Form(caption='Exception: {}'.format(ex.__class__.__name__),
left=100, top=100, width=350, height=180)
frm.resizable = False
msg = Label(frm, left=45, top=5, width=305, height=40, caption=ex.message)
msg.wordwrap = True
img = Image(frm, left=5, top=15, width=32, height=32, file=err_icon)
trace = Memo(frm, left=5, top=55, width=335, height=90)
trace.text = stacktrace
def close_form():
frm.close()
btn = Button(frm, left=140, top=148, width=65, height=27, caption="Close")
btn.on_click = close_form
frm.show_modal()
示例14: render_title_menu_screen
def render_title_menu_screen(app, MOUSE_POS=None):
'''(App, tuple) -> NoneType'''
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
app.ui_elements.clear() # remove old ui elements in old screen, if any
FONT_FAMILY = join("data", "font", "Alien-Encounters-Regular.ttf")
FONT_SIZE = 30
FONT_COLOUR = WHITE
app.background = BLACK
app.window.fill(BLACK)
# title
TEXT = app.title
COORD = (100, 100)
title_label = Label(TEXT, COORD, FONT_FAMILY, FONT_SIZE, FONT_COLOUR)
app.ui_elements.append(title_label)
title_label.render(app.window)
# levels button
COORD = (100, 200)
WIDTH = 800
HEIGHT = 40
TEXT = "levels"
FOO = render_level_menu_screen
levels_button = Button(COORD, WIDTH, HEIGHT, TEXT, FONT_FAMILY, FONT_SIZE,
COLOUR=FONT_COLOUR, FOO=FOO)
app.ui_elements.append(levels_button)
levels_button.render(app.window)
# exit button
COORD = (100, 300)
WIDTH = 800
HEIGHT = 40
TEXT = "exit"
FOO = exit_app
exit_button = Button(COORD, WIDTH, HEIGHT, TEXT, FONT_FAMILY, FONT_SIZE,
COLOUR=FONT_COLOUR, FOO=FOO)
app.ui_elements.append(exit_button)
exit_button.render(app.window)
app.to_update.append(None) # update whole software display
app.status = 0
示例15: _compute_labels
def _compute_labels(self, gc):
"""Generates the labels for tick marks.
Overrides PlotAxis.
"""
try:
self.ticklabel_cache = []
for text in self._tick_label_list:
ticklabel = Label(text=text, font=self.tick_label_font,
color=self.tick_label_color,
rotate_angle=self.label_rotation)
self.ticklabel_cache.append(ticklabel)
self._tick_label_bounding_boxes = [array(ticklabel.get_bounding_box(gc), float64) for ticklabel in self.ticklabel_cache]
except:
print_exc()
return