def add_to_grid(self, grid: Gtk.Grid):
if self.tenant:
raise Exception('Already added to a grid')
tenant = self.tenant = GridRowTenant(grid)
base = 0
if tenant.base_row > 0:
tenant.attach(Gtk.Separator(visible=True, hexpand=True), width=FINISHED_JOB_COLUMNS)
base += 1
tenant.attach(self.title_box, top=base)
tenant.attach(self.finish_box, top=base, left=1)
tenant.attach(self.buttons, top=base, left=2)
tenant.attach(self.extra, top=base+1, width=FINISHED_JOB_COLUMNS)
python类Grid()的实例源码
def add_to_grid(self, grid: Gtk.Grid):
if self.tenant:
raise Exception('Already added to a grid')
tenant = self.tenant = GridRowTenant(grid)
base = 0
if tenant.base_row > 0:
tenant.attach(Gtk.Separator(visible=True, hexpand=True), width=FINISHED_JOB_COLUMNS)
base += 1
tenant.attach(self.title_box, top=base)
tenant.attach(self.finish_box, top=base, left=1)
tenant.attach(self.buttons, top=base, left=2)
tenant.attach(self.extra, top=base + 1, width=FINISHED_JOB_COLUMNS)
def __init__(self):
Gtk.Grid.__init__(self)
self.contentbox = content_box()
stepgrid = step_grid(self)
self.attach(stepgrid,0,0,1,1)
self.attach(self.contentbox,0,1,1,1)
def __init__(self, n_col):
Gtk.Grid.__init__(self)
self.n_col = n_col
self.widget_count = 0
self.set_column_spacing(2)
self.set_row_spacing(2)
def __init__(self):
Gtk.Window.__init__(self, title="TextView Example")
self.set_default_size(-1, 350)
self.grid = Gtk.Grid()
self.add(self.grid)
self.create_textview()
self.create_toolbar()
self.create_buttons()
def __init__(self,MainGrid):
Gtk.Grid.__init__(self)
self.MainGrid=MainGrid
self.imgbox = img_box(self)
self.attach(self.imgbox,0,0,1,1)
self.set_hexpand(True)
self.set_valign(Gtk.Align(3))
def __init__(self,window):
Gtk.Grid.__init__(self)
self.window = window
self.set_column_spacing(25)
#arbitrary initialisations for underdeveloped stuff
self.stepsbox = steps_box(self)
self.contentgrid = content_grid2(self)
#end of arbitary stuff
self.attach(self.stepsbox,0,0,1,1)
self.attach_next_to(self.contentgrid,self.stepsbox,Gtk.PositionType.RIGHT,1,1)
self.name = "HELLO"
def __init__(self):
Gtk.Window.__init__(self, title="FileChooser Example")
self.maximize()
self.fold_str = None
self.grid = Gtk.Grid(column_homogeneous=False,
column_spacing=10,
row_spacing=0)
self.add(self.grid)
button1 = Gtk.Button("Choose File")
button1.connect("clicked", self.on_file_clicked)
self.grid.add(button1)
self.text_file = Gtk.Entry()
self.grid.attach(self.text_file,1,0,4,1)
button2 = Gtk.Button("Choose Folder")
button2.connect("clicked", self.on_folder_clicked)
button2.set_relief(Gtk.ReliefStyle(0))
self.grid.attach_next_to(button2,button1,Gtk.PositionType.BOTTOM,1,1)
self.text_folder = Gtk.Entry()
self.grid.attach(self.text_folder,1,1,4,1)
but3=buttontest()
self.grid.attach(but3,0,2,1,1)
def __init__(self,parent):
Gtk.Grid.__init__(self)
self.set_border_width(10)
self.vbox = Gtk.VBox(spacing=6)
self.vbox = Gtk.Box(spacing=6)
self.add(self.vbox)
self.button1 = Gtk.ToggleButton("Button1")
self.button1.connect("toggled", self.on_button_toggled, "1")
self.button1.set_active(True)
#self.button1img = Gtk.Image.new_from_icon_name("filenew", Gtk.IconSize.MENU)
#self.button1.set_image(self.button1img)
self.vbox.pack_start(self.button1, True, True, 0)
self.button2 = Gtk.ToggleButton("Button 2")
self.button2.connect("toggled", self.on_button_toggled, "2")
self.vbox.pack_start(self.button2, True, True, 0)
self.button3 = Gtk.ToggleButton("Button 3")
self.button3.connect("toggled", self.on_button_toggled, "3")
self.vbox.pack_start(self.button3, True, True, 0)
self.attach(self.button1, 0, 0, 1, 1)
self.attach(self.button2, 1, 0, 3, 1)
self.attach(self.button3, 2, 0, 1, 1)
def __init__(self,parent):
Gtk.Grid.__init__(self)
self.set_column_spacing(25)
step = stepbox(self)
main= mainbox(self)
side = sidebox(self)
self.attach(step, 0, 0, 20, 10)
self.attach(main, 21, 0, 40, 10)
self.attach(side, 61, 0, 10, 10)
def __init__(self, years=4):
Gtk.Grid.__init__(self)
# Tells which position the rightmost column is
self.width = 0
self.nth = {
1: "First",
2: "Second",
3: "Third",
4: "Fourth",
5: "Fifth",
6: "Sixth"
}
self.year_map = {}
self.set_margin_top(10)
self.set_margin_bottom(10)
self.set_margin_start(10)
self.set_margin_end(10)
horizontal_separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL)
horizontal_separator.set_margin_top(5)
horizontal_separator.set_margin_bottom(10)
self.attach(horizontal_separator, 0, 1, 2, 1)
for x in range(1,years+1):
self.add_year(x)
self.show_all()
def __init__(self):
#########Setting_Basic_Window_Size&Border########################################
Gtk.Window.__init__(self,title="Impress Writer")
self.set_border_width(1)
self.set_default_size(1366,768)
###################Header_Bar###################################################
hb=Gtk.HeaderBar()
hb.set_show_close_button(True)
hb.props.title="Impress Writer"
self.set_titlebar(hb)
#############################Adding_Overall_Grid################################
self.grid=Gtk.Grid()
self.add(self.grid)
###################Adding_Toolbar############################################
self.create_toolbar_top()
###########Adding_TextView#################################################
self.text_grid = Gtk.Grid()
self.create_main_view()
self.create_textview()
self.create_toolbar()
self.create_buttons()
#############Adding synonyms flowbox######################################
self.create_synonyms_flowbox()
def __init__(self, app):
super().__init__()
self.set_application(app)
self.set_title(version.APP_NAME)
self.set_position(Gtk.WindowPosition.CENTER)
self.set_skip_taskbar_hint(True)
self.set_skip_pager_hint(True)
self.set_urgency_hint(True)
self.set_decorated(False)
self.set_name('MainWindow')
self.set_icon_from_file(common.ICON_PATH)
self.set_keep_above(True)
self.set_keep_below(False)
self.set_type_hint(Gdk.WindowTypeHint.NORMAL)
self.stick()
self.maximize()
screen = self.get_screen()
visual = screen.get_rgba_visual()
self.set_visual(visual)
self.grid = Gtk.Grid()
self.grid.set_valign(Gtk.Align.FILL)
self.grid.set_halign(Gtk.Align.FILL)
self.grid.set_vexpand(True)
self.grid.set_hexpand(True)
self.add(self.grid)
def createSubTab(Tab, notebook, label):
Tab.set_border_width(10)
notebook.append_page(Tab, Gtk.Label(label))
Frame = Gtk.Frame()
Tab.add(Frame)
Grid = Gtk.Grid()
Frame.add(Grid)
return Grid
# Setting Columns in TreeView
def createSubFrame(Tab):
Frame = Gtk.Frame()
Tab.add(Frame)
grid = Gtk.Grid()
Frame.add(grid)
return grid
def create_widgets(self):
self.grid = Gtk.Grid()
self.file_selecter = FileSelecter()
self.paint_area = PaintArea()
self.paint_background = BackgroundColor()
self.paint_color = PaintColor()
self.size = Size()
self.var_list = VariableList()
self.name = Gtk.Entry()
self.name.get_buffer().set_text('MyTheme', -1)
export = Gtk.Button('Export')
export.connect('clicked', self.export)
load = Gtk.Button('Load')
load.connect('clicked', self.load)
paned2 = Gtk.Paned()
paned2.set_position(200)
paned2.add1(self.paint_area)
paned2.add2(self.var_list)
paned = Gtk.Paned()
paned.set_position(200)
paned.add1(self.file_selecter)
paned.add2(paned2)
self.grid.attach(paned, 0, 0, 10, 10)
self.grid.attach(self.paint_background, 1, 10, 1, 1)
self.grid.attach(self.paint_color, 2, 10, 1, 1)
self.grid.attach(self.size, 3, 10, 1, 1)
self.grid.attach(export, 8, 10, 1, 1)
self.grid.attach(load, 9, 10, 1, 1)
self.grid.attach(self.name, 7, 10, 1, 1)
self.add(self.grid)
return None
def make_plugin_grid(icon, plg, mdesc, mexts, mtype):
grid = Gtk.Grid()
grid.set_column_homogeneous(False)
grid.set_property("margin", 20)
plg_grid = Gtk.Grid()
plg_grid.set_column_spacing(10)
plg_grid.attach(icon, 0, 0, 1, 1)
plg_grid.attach(plg, 1, 0, 1, 1)
mime_grid = Gtk.Grid()
mime_grid.set_hexpand(True)
mime_grid.set_column_spacing(10)
mime_grid.set_row_spacing(5)
mime_grid.set_column_homogeneous(True)
mime_grid.set_row_homogeneous(False)
mime_grid.attach(make_mime_label("<b>{}</b>".format(_("MIME Type")), 1,), 0, 0, 1, 1)
mime_grid.attach(make_mime_label("<b>{}</b>".format(_("Description")), 1), 1, 0, 1, 1)
mime_grid.attach(make_mime_label("<b>{}</b>".format(_("Extension")), 1), 2, 0, 1, 1)
for c, i in enumerate(mtype): mime_grid.attach(make_mime_label(i, 0), 0, c+1, 1, 1)
for c, i in enumerate(mdesc): mime_grid.attach(make_mime_label(i, 0), 1, c+1, 1, 1)
for c, i in enumerate(mexts):
if not i: i = ""
else: i = ", ".join(i)
mime_grid.attach(make_mime_label(i, 0), 2, c+1, 1, 1)
frame_mime = Gtk.Frame(name="frame_mime")
frame_mime.add(mime_grid)
grid.attach(plg_grid, 0, 0, 1, 1)
grid.attach(frame_mime, 0, 1, 1, 1)
return grid
def setting_element(option, title, value, tp, desc, list):
grid = Gtk.Grid()
label = Gtk.Label()
label.set_alignment(0.0, 0.5)
label.set_property("margin-bottom", 10)
if desc: label.set_markup(\
"{}\n<span size='small'>{}</span>".format(_(title), _(desc)))
else: label.set_markup(_(title))
if tp == "1":
elem = Gtk.Entry(name=option)
elem.set_width_chars(30)
elem.set_text(value)
if tp == "2":
elem = Gtk.ComboBoxText(name=option)
elem.set_entry_text_column(0)
for i in list: elem.append_text(i)
elem.set_active(int(value))
grid.attach(label, 0, 0, 1, 1)
grid.attach(elem, 0, 1, 1, 1)
grid.set_property("margin", 10)
return grid
def on_created_destination(self, download, destination):
name = get_filename(destination)
unname = unparse(destination)
item = Gtk.ModelButton(name=unname)
item.set_alignment(0.0, 0.5)
item.set_label("<span size='small'>{}: {}</span>\r<span size='x-small'>{}: {}</span>"\
.format(_("Downloading"), minify(html.escape(name), 50),\
_("In"), minify(html.escape(destination.replace("file://", "")), 50)))
item.get_child().set_use_markup(True)
item.get_child().set_padding(5, 5)
item.connect("clicked", lambda x: subprocess.Popen\
([app_launcher, os.path.dirname(destination)]))
canc = make_button(make_icon("edit-delete.svg"), None, False)
canc.connect("clicked", lambda x: [download.cancel(),\
self.dlview.remove(grid), self.on_cancel_download()])
rest = make_button(make_icon("refresh.svg"), None, False)
rest.connect("clicked", lambda x: [download.cancel(),\
self.dlview.remove(grid), self.on_cancel_download(),\
self.on_restart_download(download)])
pbar = Gtk.ProgressBar(name=unname)
grid = Gtk.Grid()
grid.set_column_spacing(0)
grid.attach(canc, 0, 0, 1, 1)
grid.attach(rest, 1, 0, 1, 1)
grid.attach(item, 2, 0, 1, 1)
grid.attach(pbar, 2, 1, 1, 1)
grid.set_column_homogeneous(False)
self.dlview.add(grid)
self.dlview.reorder_child(grid, 0)
self.on_download_menu()
def preparePostEditingAnalysis(self):
self.saveChangedFromPostEditing()
self.diff_tab_grid = Gtk.Grid()
self.diff_tab_grid.set_row_spacing(1)
self.diff_tab_grid.set_column_spacing(20)
self.tables["diff_table"] = Table("diff_table",self.post_editing_source,self.post_editing_reference, self.preparePostEditingAnalysis_event,self.preparePostEditingAnalysis, self.calculate_statistics_event, self.diff_tab_grid,self.output_directory)
self.addDifferencesTab()
self.tables["translation_table"].save_post_editing_changes_button.hide()
self.visibility_of_statistics_menu = False
self.tables["translation_table"].statistics_button.show()