本文整理汇总了Python中background.Background.set_num_rows方法的典型用法代码示例。如果您正苦于以下问题:Python Background.set_num_rows方法的具体用法?Python Background.set_num_rows怎么用?Python Background.set_num_rows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类background.Background
的用法示例。
在下文中一共展示了Background.set_num_rows方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AllDayTasks
# 需要导入模块: from background import Background [as 别名]
# 或者: from background.Background import set_num_rows [as 别名]
class AllDayTasks(Gtk.DrawingArea):
def __init__(self, parent, rows=1, cols=7):
super(Gtk.DrawingArea, self).__init__()
self.par = parent
self.num_rows = rows
self.num_columns = cols
self.background = Background(rows, cols)
self.padding = 1.5
self.font = "Courier"
self.font_size = 12
self.font_color = (0.35, 0.31, 0.24)
self.link_color = (0, 0, 255, 0.5) # default blue link color
self.today_cell = (None, None)
self.selected_task = None
self.faded_cells = []
self.cells = []
self.labels = None
self.label_height = self.font_size
self.overflow_links = []
self.connect("draw", self.draw)
# drag-and-drop signals and events
self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK
| Gdk.EventMask.BUTTON_RELEASE_MASK
| Gdk.EventMask.BUTTON1_MOTION_MASK
| Gdk.EventMask.POINTER_MOTION_MASK)
def get_label_height(self):
if self.labels:
return self.label_height
return 0
def set_labels(self, labels):
self.labels = labels
def set_num_rows(self, rows):
self.num_rows = rows
self.background.set_num_rows(rows)
def set_font(self, font):
self.font = font
def set_font_size(self, size):
self.font_size = size
def set_font_color(self, color):
self.font_color = color
def set_line_color(self, color):
self.background.set_line_color(color)
def set_background_color(self, color):
self.background.set_background_color(color)
def get_day_width(self):
return self.get_allocation().width / float(self.num_columns)
def get_week_height(self):
return self.get_allocation().height / float(self.num_rows)
def set_tasks_to_draw(self, drawtasks):
self.drawtasks = drawtasks
def highlight_cells(self, ctx, cells, color, alpha=0.5):
alloc = self.get_allocation()
for cell in cells:
row, col = cell
if 0 <= row < self.num_rows and 0 <= col < self.num_columns:
ctx.save()
self.background.highlight_cell(ctx, row, col, alloc,
color, alpha)
ctx.restore()
def set_today_cell(self, row, col):
if 0 <= row < self.num_rows and 0 <= col < self.num_columns:
self.today_cell = (row, col)
else:
self.today_cell = (None, None)
def draw(self, widget, ctx):
ctx.set_line_width(0.8)
ctx.set_font_size(self.font_size)
ctx.select_font_face(self.font, cairo.FONT_SLANT_NORMAL,
cairo.FONT_WEIGHT_NORMAL)
# first draw background
ctx.save()
alloc = self.get_allocation()
self.set_line_color(color=(0.35, 0.31, 0.24, 0.15))
row, col = self.today_cell
if row is not None and col is not None and row >= 0 and col >= 0:
self.background.highlight_cell(ctx, row, col, alloc)
self.background.draw(ctx, alloc, vgrid=True, hgrid=True)
ctx.restore()
# then draw labels, if any (used only on month_view)
if self.labels:
#.........这里部分代码省略.........