def init(self): # table table = make_table('main', False) table.Size = Size(580, 700) table.Location = Point(10, 10) table.ColumnCount = 2 table.Columns[0].Name = 'Key' table.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable table.Columns[0].ReadOnly = True table.Columns[0].DefaultCellStyle.SelectionBackColor = Color.FromArgb(238, 238, 238) table.Columns[0].DefaultCellStyle.BackColor = Color.FromArgb(238, 238, 238) table.Columns[1].Name = 'Value' table.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable keys = sorted(self.settings.keys()) for key in keys: table.Rows.Add(key, self.settings[key]) self.table = table # buttons ok = Button() ok.Text = 'OK' ok.DialogResult = DialogResult.OK cancel = Button() cancel.Text = 'Cancel' cancel.DialogResult = DialogResult.Cancel buttons = FlowLayoutPanel() buttons.FlowDirection = FlowDirection.RightToLeft # buttons.BorderStyle = BorderStyle.None buttons.Controls.Add(cancel) buttons.Controls.Add(ok) buttons.Size = Size(580, 30) buttons.Location = Point(10, 720) # layout self.ClientSize = Size(600, 800) self.Controls.Add(table) self.Controls.Add(buttons)
def init(self): # tabs tabs = TabControl() tabs.Size = Size(580, 700) tabs.Location = Point(10, 10) # buttons ok = Button() ok.Text = 'OK' ok.DialogResult = DialogResult.OK cancel = Button() cancel.Text = 'Cancel' cancel.DialogResult = DialogResult.Cancel buttons = FlowLayoutPanel() buttons.FlowDirection = FlowDirection.RightToLeft buttons.BorderStyle = BorderStyle.None buttons.Controls.Add(cancel) buttons.Controls.Add(ok) buttons.Size = Size(580, 30) buttons.Location = Point(10, 720) self.ClientSize = Size(600, 800) self.Controls.Add(tabs) self.Controls.Add(buttons) # pages and tables index = 0 for name in self.settings: page = make_page(name, name, index) page.TabIndex = index settings = self.settings[name] table = make_table(name) table.ColumnCount = 2 table.Columns[0].Name = 'Key' table.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable table.Columns[0].ReadOnly = True table.Columns[ 0].DefaultCellStyle.SelectionBackColor = Color.FromArgb( 238, 238, 238) table.Columns[0].DefaultCellStyle.BackColor = Color.FromArgb( 238, 238, 238) table.Columns[1].Name = 'Value' table.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable keys = sorted(settings.keys()) for key in keys: table.Rows.Add(key, settings[key]) page.Controls.Add(table) tabs.Controls.Add(page) self.tables[name] = table index += 1
def init(self): # table table = make_table('main', False) table.Size = Size(980, 700) table.Location = Point(10, 10) table.ColumnCount = len(self.names) + 1 table.Columns[0].Name = 'Key' table.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable table.Columns[0].ReadOnly = True table.Columns[0].DefaultCellStyle.SelectionBackColor = Color.FromArgb( 238, 238, 238) table.Columns[0].DefaultCellStyle.BackColor = Color.FromArgb( 238, 238, 238) for i in range(len(self.names)): column = table.Columns[i + 1] column.Name = self.names[i] column.SortMode = DataGridViewColumnSortMode.NotSortable if self.types: if self.types[i] == 'f': column.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill else: column.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells keys = sorted(self.attributes.keys(), key=int) for key in keys: values = [self.attributes[key][name] for name in self.names] objects = [key] + values table.Rows.Add(*objects) self.table = table # buttons ok = Button() ok.Text = 'OK' ok.DialogResult = DialogResult.OK cancel = Button() cancel.Text = 'Cancel' cancel.DialogResult = DialogResult.Cancel buttons = FlowLayoutPanel() buttons.FlowDirection = FlowDirection.RightToLeft # buttons.BorderStyle = BorderStyle.None buttons.Controls.Add(cancel) buttons.Controls.Add(ok) buttons.Size = Size(980, 30) buttons.Location = Point(10, 720) # layout self.ClientSize = Size(1000, 800) self.Controls.Add(table) self.Controls.Add(buttons)
def init(self): ok = Button() ok.Text = 'OK' ok.DialogResult = DialogResult.OK cancel = Button() cancel.Text = 'Cancel' cancel.DialogResult = DialogResult.Cancel buttonlayout = FlowLayoutPanel() buttonlayout.Height = 30 buttonlayout.Anchor = AnchorStyles.Bottom | AnchorStyles.Right buttonlayout.FlowDirection = FlowDirection.RightToLeft buttonlayout.BorderStyle = BorderStyle.None buttonlayout.Controls.Add(cancel) buttonlayout.Controls.Add(ok) formlayout = TableLayoutPanel() formlayout.Dock = DockStyle.Fill formlayout.BorderStyle = BorderStyle.None formlayout.ColumnCount = 1 formlayout.RowCount = 2 formlayout.RowStyles.Add(RowStyle(SizeType.Percent, 100)) formlayout.Controls.Add(table, 0, 0) formlayout.Controls.Add(buttonlayout, 0, 1) self.Controls.Add(formlayout)
def make_button_layout(): layout = FlowLayoutPanel() layout.BorderStyle = BorderStyle.None layout.FlowDirection = FlowDirection.RightToLeft return layout