viewergrid.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:PyFlowChart 作者: steelcowboy 项目源码 文件源码
def __init__(self, year):
        Gtk.Grid.__init__(self)
        self.year = year
        self.selected_quarter = None 

        self.quarters = {
                0: "Fall",
                1: "Winter",
                2: "Spring",
                3: "Summer"
        }
        self.hidden = {x: False for x in [0,2,4,6]} 

        self.quarter_map = {}

        self.set_vexpand(True)
        self.set_hexpand(True)
        self.set_valign(Gtk.Align.FILL)
        self.set_halign(Gtk.Align.FILL)

        horizontal_separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL)
        horizontal_separator.set_margin_top(2)
        horizontal_separator.set_margin_bottom(5)
        self.attach(horizontal_separator, 0, 1, 2, 1)

        for x in [0,2,4,6]:
            if x < 6:
                # Don't insert a column if it's at position 0 
                if x: self.insert_column(x)
                # Insert column to expand horizontal separator
                self.insert_column(x+1)

                vertical_separator = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL)
                vertical_separator.set_margin_start(5)
                vertical_separator.set_margin_end(5)
                self.attach(vertical_separator, x+1, 0, 1, 3)

            quarter = quarterColumn(self.year, self.quarters[x/2])

            label_box = Gtk.EventBox()
            label = Gtk.Label(self.quarters[x/2])
            label_box.add(label)
            label_box.connect('button-press-event', self.quarter_clicked) 
            self.attach(label_box, x, 0, 1, 1)

            self.quarter_map[x/2] = quarter 
            self.attach(quarter, x, 2, 1, 1)

        self.hide_menu = Gtk.Menu()
        hide_button = Gtk.MenuItem.new_with_label('Hide')
        self.hide_menu.append(hide_button)
        hide_button.show()
        hide_button.connect('activate', self.toggle_quarter)


        self.show_all()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号