def _populateProductTypeGrpKey(self): self.tlpKeyGrpProductTypeKey.RowCount = len(self.productNames) i = -1 for name in self.productNames: i+=1 #must put str values into control because of TableLayoutPanel lblProduct = Label() lblProduct.Text = name lblNumber = Label() lblNumber.Text = str(i) self.tlpKeyGrpProductTypeKey.Controls.Add(lblProduct) self.tlpKeyGrpProductTypeKey.Controls.Add(lblNumber)
def __init__(self): #the __init__ method inside a class is its constructor self.Text = "AU London" #text that appears in the GUI titlebar self.Icon = Icon.FromHandle(icon.GetHicon()) self.BackColor = Color.FromArgb(255, 255, 255) self.WindowState = FormWindowState.Normal self.CenterToScreen() self.BringToFront() self.TopMost = True screenSize = Screen.GetWorkingArea(self) self.Width = screenSize / 4 self.Height = screenSize / 4 uiWidth = self.DisplayRectangle.Width uiHeight = self.DisplayRectangle.Height spacing = 10 userMessage = Label() font = Font("Helvetica", 10) userMessage.Text = message userMessage.Font = font userMessage.Location = Point(spacing, spacing) userMessage.Size = Size(uiWidth - (spacing * 2), (uiHeight / 4)) self.Controls.Add(userMessage)
def __init__(self, plan): # Set the size of the form self.Size = Size(500, 200) # Set title of the form self.Text = 'Approximate fiducial location' # Add a label label = Label() label.Text = 'Type the approximate fiducial location in mm' label.Location = Point(15, 15) label.AutoSize = True self.Controls.Add(label) # Add a TextBox self.textbox = TextBox() self.textbox.Location = Point(15, 60) self.textbox.Width = 150 self.Controls.Add(self.textbox) # Add button to press OK and close the form button = Button() button.Text = 'OK' button.AutoSize = True button.Location = Point(15, 100) button.Click += self.ok_button_clicked self.Controls.Add(button)
def __init__(self): #the __init__ method inside a class is its constructor self.Text = "AU London" #text that appears in the GUI titlebar self.Icon = Icon.FromHandle(icon.GetHicon()) #takes a bitmap image and converts to a file that can be used as a Icon for the titlebar self.BackColor = Color.FromArgb(255, 255, 255) self.WindowState = FormWindowState.Normal # set maximised minimised or normal size GUI self.CenterToScreen() # centres GUI to the middle of your screen self.BringToFront() #brings the GUI to the front of all opens windows. self.Topmost = True # true to display the GUI infront of any other active forms screenSize = Screen.GetWorkingArea(self) #get the size of the computers main screen, as the form will scale differently to different sized screens self.Width = screenSize.Width / 4 #set the size of the form based on the size of the users screen. this helps to ensure consistant look across different res screens. self.Height = screenSize.Height / 4 uiWidth = self.DisplayRectangle.Width #get the size of the form to use to scale form elements uiHeight = self.DisplayRectangle.Height #self.FormBorderStyle = FormBorderStyle.FixedDialog # fixed dialog stops the user from adjusting the form size. Recomended disabling this when testing to see if elements are in the wrong place. self.userOutput = userOutputDefaultStr #create a container to store the output from the form self.runNextOutput = False #set these default values #############-------------\-------------############# spacing = 10 #spacing size for GUI elements to form a consistent border # creates the text box for a info message userMessage = Label() #label displays texts font = Font("Helvetica ", 10) userMessage.Text = message userMessage.Font = font userMessage.Location = Point(spacing, spacing) #all location require a point object from system.Drawing to set the location. userMessage.Size = Size(uiWidth-(spacing*2),(uiHeight/4)) #size the control with the width of the GUI to ensure it scales with different screen self.Controls.Add(userMessage) #this adds control element to the GUI
def __build_label(self, series_ref): """ builds and returns the main text label for this form """ # 1. compute the best possible full name for the given SeriesRef name_s = series_ref.series_name_s publisher_s = series_ref.publisher_s vol_year_n = series_ref.volume_year_n vol_year_s = sstr(vol_year_n) if vol_year_n > 0 else "" fullname_s = "" if name_s: if publisher_s: if vol_year_s: fullname_s = "'" + name_s + "' (" + publisher_s + ", " + vol_year_s + ")" else: fullname_s = "'" + name_s + "' (" + publisher_s + ")" else: fullname_s = "'" + name_s + "'" label = Label() label.UseMnemonic = False sep = " " if len(fullname_s) > 40 else "\n" label.Text = i18n.get("IssueFormChooseText").format(fullname_s, sep) if self.__config.show_covers_b: label.Location = Point(218, 20) label.Size = Size(480, 40) else: label.Location = Point(10, 20) label.Size = Size(680, 40) return label
def __init__(self): self.Title="Timer" self.timer1=Timer() self.timer1.Interval=1000 self.timer1.Tick+=self.timer1_tick label1=Label() label1.AutoSize=True label1.Location=Point(41,22) label1.Text="00:00:00" label1.Font=Font("MS UI Gothic",24.0,FontStyle.Regular) self.label1=label1 self.Controls.Add(self.label1) clientwidth=255 b1=Button() b1.Location=Point((clientwidth-b1.Width*2)/3,68) b1.Text="Click" b1.Click+=self.start_Click self.Controls.Add(b1) b2=Button() b2.Location=Point((clientwidth-b1.Width*2)*2/3+b1.Width,68) b2.Text="Stop" b2.Click+=self.stop_Click self.Controls.Add(b2) self.ClientSize=Size(clientwidth,103) self.Text="Stop Watch" self.StartPosition=FormStartPosition.CenterScreen
def _initialize_components(self): self._generate_menu_strip() self._create_buttons() flags_description = Label() flags_description.Parent = self flags_description.Text = 'Flags:' flags_description.Location = Point(10, 30) flags_description.Size = TextRenderer.MeasureText( flags_description.Text, flags_description.DefaultFont) self._result = Label() self._result.Parent = self self._result.Text = '' self._result.Size = TextRenderer.MeasureText(self._result.Text, self._result.DefaultFont) self._result.Location = Point( self.Size.Width / 2 - self._result.Size.Width / 2 - 5, 30) self._flags_counter = Label() self._flags_counter.Parent = self self._flags_counter.Location = Point(45, 30) self._flags_counter.Size = Size(30, 20) self._label_timer = Label() self._label_timer.Parent = self self._label_timer.TextAlign = ContentAlignment.MiddleRight self._label_timer.Location = Point(self.Size.Width - 70, 30) self._label_timer.Size = Size(40, 20)
def __build_label(self, series_ref): ''' builds and returns the main text label for this form ''' # 1. compute the best possible full name for the given SeriesRef name_s = series_ref.series_name_s publisher_s = series_ref.publisher_s vol_year_n = series_ref.volume_year_n vol_year_s = sstr(vol_year_n) if vol_year_n > 0 else '' fullname_s = '' if name_s: if publisher_s: if vol_year_s: fullname_s = "'"+name_s+"' ("+publisher_s+", " + vol_year_s + ")" else: fullname_s = "'"+name_s+"' (" + publisher_s + ")" else: fullname_s = "'"+name_s+"'" label = Label() label.UseMnemonic = False sep = ' ' if len(fullname_s) > 40 else '\n' label.Text = i18n.get("IssueFormChooseText").format(fullname_s, sep) if self.__config.show_covers_b: label.Location = Point(218, 20) label.Size = Size(480, 40) else: label.Location = Point(10, 20) label.Size = Size(680, 40) return label
def _initializeUserInterface(self): self.Size = Size(1600, 500) self.tlpMain.ColumnCount = len(self.columnNames) self.tlpMain.RowCount = 2 self.tlpMain.Size = self.ClientRectangle.Size #create list titles for name in self.columnNames: lbl = Label() lbl.Text = name lbl.Font = Font("Microsoft Sans Serif", 12, FontStyle.Bold) lbl.Height = 50 self.tlpMain.Controls.Add(lbl) #create lists for name in self.columnNames: lst = ListBox() lst.Name = name lst.Font = Font("Microsoft Sans Serif", 10) lst.Width = 135 if name.ToLower() == 'attribute': lst.Width = 300 if name.ToLower() == 'mode': lst.Width = 215 lst.Height = self.ClientRectangle.Height - (lbl.Height * 2) self.tlpMain.Controls.Add(lst) self._populateLists(lst)
def __build_advancedtab(self): ''' builds and returns the "Advanced" Tab for the TabControl ''' tabpage = TabPage() tabpage.Text = i18n.get("ConfigFormAdvancedTab") # 1. --- a description label for this tabpage label = Label() label.UseMnemonic = False label.AutoSize = True label.Location = Point(14, 25) label.Size = Size(299, 17) label.Text = i18n.get("ConfigFormAdvancedText") # 2. --- build the update checklist (contains all the 'data' checkboxes) tbox = RichTextBox() tbox.Multiline = True tbox.MaxLength = 65536 tbox.WordWrap = True tbox.Location = Point(15, 50) tbox.Size = Size(355, 200) menu = ContextMenu() items = menu.MenuItems items.Add(MenuItem(i18n.get("TextCut"), lambda s, ea: tbox.Cut())) items.Add(MenuItem(i18n.get("TextCopy"), lambda s, ea: tbox.Copy())) items.Add(MenuItem(i18n.get("TextPaste"), lambda s, ea: tbox.Paste())) tbox.ContextMenu = menu self.__advanced_tbox = tbox # 3. --- add 'em all to the tabpage tabpage.Controls.Add(label) tabpage.Controls.Add(self.__advanced_tbox) return tabpage
def __init__(self): self.Text = "Spreadsheet to HTML" self.Width = 220 self.Height = 90 self.FormBorderStyle = FormBorderStyle.Fixed3D self.openDialog = OpenFileDialog() self.openDialog.Title = "Choose a Python Spreadsheet File" self.openDialog.Filter = 'Python files (*.py)|*.py|All files (*.*)|*.*' self.folderDialog = FolderBrowserDialog() self.folderDialog.ShowNewFolderButton = True self.folderDialog.Description = "Choose a directory to save the HTML files in." l = Label() l.AutoSize = True l.Location = Point(50, 5) l.Text = "Choose a Spreadsheet" b = Button(Text="Choose") b.Click += self.convert b.Location = Point(70, 30) self.Controls.Add(l) self.Controls.Add(b)
def __build_label(self, search_terms_s, num_matches_n): ''' Builds and return the text label for this form. 'search_terms_s' -> user's search string that was used to find series 'num_matches_n' -> number of series (table rows) the user's search matched ''' label = Label() label.UseMnemonic = False label.Location = Point(10, 20) label.Size = Size(480, 40) if num_matches_n > 1: label.Text = i18n.get("SeriesFormChooseText")\ .format(search_terms_s, num_matches_n ) else: label.Text = i18n.get("SeriesFormConfirmText").format(search_terms_s) return label
def add_heading_label(text, panel): # add heading label label = Label() label.Parent = panel label.Text = text label.AutoSize = True label.Font = HEADER_FONT label.Margin = Padding(0, 5, 0, 5)
def addNameLabel(self, name, imageName, location): label = Label() label.Parent = self label.AutoSize = True label.Location = location label.Text = name label.MouseEnter += lambda *_: self.switchImage(imageName) label.MouseLeave += self.resetImage
def ShowDialog(self, controller, title, text, default_input, exp_index): # set controller self.controller = controller # set exp index self.exp_index = exp_index # initialize exp name variable self.exp_name = None # initialize invalid name label self.invalid_name_label = None # create the form self.dialog_window = Form() self.dialog_window.AutoSize = True self.dialog_window.Width = 400 self.dialog_window.MaximumSize = Size(400, 160) self.dialog_window.StartPosition = FormStartPosition.CenterScreen self.dialog_window.Text = title self.dialog_window.FormBorderStyle = FormBorderStyle.FixedSingle # create the main panel self.panel = FlowLayoutPanel() self.panel.Parent = self.dialog_window self.panel.BackColor = DIALOG_COLOR self.panel.Dock = DockStyle.Top self.panel.Padding = Padding(10, 10, 0, 10) self.panel.FlowDirection = FlowDirection.TopDown self.panel.WrapContents = False self.panel.AutoSize = True self.panel.Font = BODY_FONT # add the dialog text exp_name_label = Label() exp_name_label.Parent = self.panel exp_name_label.Text = text exp_name_label.Width = self.panel.Width exp_name_label.AutoSize = True exp_name_label.Margin = Padding(0, 5, 0, 0) # add the textbox self.exp_name_box = TextBox() self.exp_name_box.Text = default_input self.exp_name_box.Parent = self.panel self.exp_name_box.Width = self.panel.Width - 30 self.exp_name_box.AutoSize = True self.exp_name_box.BackColor = BUTTON_PANEL_COLOR self.exp_name_box.Font = Font(BODY_FONT.FontFamily, 9) # add save button panel self.add_save_button_panel() # show the dialog self.dialog_window.ShowDialog() # return the exp name return self.exp_name
def __build_label(self): ''' builds and returns the text label for this form ''' label = Label() label.UseMnemonic = False label.Location = Point(10, 110 if self.__fail_label_is_visible else 10) label.Size = Size(415, 20) label.Text = i18n.get("SearchFormText") return label
def add_param_label(text, panel): # add param label label = Label() label.Parent = panel label.Text = text label.AutoSize = True label.Font = BODY_FONT label.Margin = Padding(0, 5, 0, 0) label.Width = panel.Width
def __build_label(self): ''' Builds and returns the label for this form. ''' label = Label() label.UseMnemonic = False label.Text = '' # updated everytime we start scraping a new comic label.Location = Point(13, 45) label.Size = Size(320, 15) label.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right label.AutoSize = False return label
def __build_label(self): ''' Builds and returns the label for this form. ''' label = Label() label.UseMnemonic = False label.Text = '' # updated everytime we start scraping a new comic label.Location = Point(13, 45) label.Size = Size(320, 15) label.Anchor = AnchorStyles.Top | AnchorStyles.Left |AnchorStyles.Right label.AutoSize = False return label
def popup(text): form = Form() form.StartPosition = FormStartPosition.CenterScreen form.Width = 300 form.Height = 300 form.Text = 'Mais pas tout le temps' label = Label() label.Text = text label.Width = 300 label.Height = 300 label.Parent = form form.ShowDialog()
def __build_fail_label(self, failed_search_s): ''' builds and returns the 'search failed' text label for this form. if there is no failed search terms, this returns None. ''' label = Label() label.UseMnemonic = False label.Location = Point(10, 10) label.Size = Size(415, 100) label.Visible = self.__fail_label_is_visible if self.__fail_label_is_visible: label.Text = i18n.get("SeriesSearchFailedText").format(failed_search_s) return label
def __build_fail_label(self, failed_search_s): ''' builds and returns the 'search failed' text label for this form. if there is no failed search terms, this returns None. ''' label = Label() label.UseMnemonic = False label.Location = Point(10, 10) label.Size = Size(415, 100) label.Visible = self.__fail_label_is_visible if self.__fail_label_is_visible: label.Text = i18n.get("SeriesSearchFailedText").format( failed_search_s) return label
def __build_skip_label(self, skipped_n): ''' Builds and returns the 'number skipped' Label for this form. 'skipped_n' -> the number of books that were skipped. ''' label = Label() label.UseMnemonic = False label.Location = Point(10, 30) label.Size = Size(280, 13) label.TextAlign = ContentAlignment.MiddleCenter label.Text = i18n.get("FinishFormSkippedSingle") if skipped_n==1 else \ i18n.get("FinishFormSkippedPlural").format(skipped_n) return label
def __build_comicvinetab(self): ''' builds and returns the "ComicVine" Tab for the TabControl ''' tabpage = TabPage() tabpage.Text = i18n.get("ConfigFormComicVineTab") tabpage.Name = "comicvine" # 1. --- a description label for this tabpage label = Label() label.UseMnemonic = False label.AutoSize = False label.Location = Point(34, 80) label.Size = Size(315, 54) label.Text = i18n.get("ConfigFormComicVineText") # 2. --- the API key text box fired_update_gui = self.__fired_update_gui class ApiKeyTextBox(TextBox): def OnTextChanged(self, args): fired_update_gui() self.__api_key_tbox = ApiKeyTextBox() tbox = self.__api_key_tbox tbox.Location = Point(34, 135) tbox.Size = Size(315, 1) menu = ContextMenu() items = menu.MenuItems items.Add(MenuItem(i18n.get("TextCut"), lambda s, ea: tbox.Cut())) items.Add(MenuItem(i18n.get("TextCopy"), lambda s, ea: tbox.Copy())) items.Add(MenuItem(i18n.get("TextPaste"), lambda s, ea: tbox.Paste())) tbox.ContextMenu = menu # 3. --- add a clickable link to send the user to ComicVine linklabel = LinkLabel() linklabel.UseMnemonic = False linklabel.AutoSize = False linklabel.Location = Point(34, 170) linklabel.Size = Size(315, 34) linklabel.Text = i18n.get("ConfigFormComicVineClickHere") linklabel.LinkClicked += self.__fired_linkclicked # 4. --- add 'em all to this tabpage tabpage.Controls.Add(label) tabpage.Controls.Add(tbox) tabpage.Controls.Add(linklabel) return tabpage
def __init__(self): self.Text = "You know I'm No Good" font = Font("Serif", 10) lyrics = Label() lyrics.Parent = self lyrics.Text = text lyrics.Font = font lyrics.Location = Point(10, 10) lyrics.Size = Size(390, 390) self.Size = Size(400,400) self.CenterToScreen()
def __build_comicvinetab(self): ''' builds and returns the "ComicVine" Tab for the TabControl ''' tabpage = TabPage() tabpage.Text = i18n.get("ConfigFormComicVineTab") tabpage.Name = "comicvine" # 1. --- a description label for this tabpage label = Label() label.UseMnemonic = False label.AutoSize = False label.Location = Point(34, 80) label.Size = Size(315, 54) label.Text = i18n.get("ConfigFormComicVineText") # 2. --- the API key text box fired_update_gui = self.__fired_update_gui class ApiKeyTextBox(TextBox): def OnTextChanged(self, args): fired_update_gui() self.__api_key_tbox = ApiKeyTextBox() tbox = self.__api_key_tbox tbox.Location = Point(34, 135) tbox.Size = Size(315, 1) menu = ContextMenu() items = menu.MenuItems items.Add( MenuItem(i18n.get("TextCut"), lambda s, ea : tbox.Cut() ) ) items.Add( MenuItem(i18n.get("TextCopy"), lambda s, ea : tbox.Copy() ) ) items.Add( MenuItem(i18n.get("TextPaste"), lambda s, ea : tbox.Paste() ) ) tbox.ContextMenu = menu # 3. --- add a clickable link to send the user to ComicVine linklabel = LinkLabel() linklabel.UseMnemonic = False linklabel.AutoSize = False linklabel.Location = Point(34, 170) linklabel.Size = Size(315, 34) linklabel.Text = i18n.get("ConfigFormComicVineClickHere") linklabel.LinkClicked += self.__fired_linkclicked # 4. --- add 'em all to this tabpage tabpage.Controls.Add(label) tabpage.Controls.Add(tbox) tabpage.Controls.Add(linklabel) return tabpage
def __init__(self): self.Text = "Hello World" self.FormBorderStyle = FormBorderStyle.Fixed3D self.Height = 150 newFont = Font("Verdana", 16, FontStyle.Bold | FontStyle.Italic) label = Label() label.AutoSize = True label.Text = "My Hello World Label" label.Location = Point(10, 50) label.BackColor = Color.Aquamarine label.ForeColor = Color.DarkMagenta label.Font = newFont self.Controls.Add(label)
def __build_label(self, books): ''' Builds and returns the Label for this form. 'books' -> a list of all the comic books being scraped. ''' plural = len(books) != 1 label = Label() label.UseMnemonic = False label.AutoSize = True label.Location = Point(9, 10) label.Size = Size(319, 13) label.Text = i18n.get("WelcomeFormTextPlural").format(len(books)) \ if plural else i18n.get("WelcomeFormTextSingle") return label
def DublicateDelays(form): offset = 18; #remove placeholder controls form.tabPageDelay.Controls.Remove(form.textBoxDelay); form.tabPageDelay.Controls.Remove(form.labelDelayName); for i in range(0,16): tb = TextBox(); #form.DublicateControl(tb, form.textBoxDelay, i, offset); DublicateControl(tb, form.textBoxDelay, i, offset); form.tabPageDelay.Controls.Add(tb); form.delayBoxes[i] = tb; lb = Label(); #form.DublicateControl(lb, form.labelDelayName, i, offset); DublicateControl(lb, form.labelDelayName, i, offset); lb.Text = form.nameBoxes[i].Text; form.tabPageDelay.Controls.Add(lb); form.delayLabels[i] = lb;
def __init__(self, imagePath): Form.__init__(self) self.Width = 346 self.Height = 215 self.images = dict((name, loadImage(imagePath, name + '.jpg')) for name in ('pycon', 'andrzej', 'michael', 'christian')) self.pictureBox = PictureBox() self.pictureBox.Parent = self self.pictureBox.Location = Point(234, 12) self.pictureBox.TabStop = False self.switchImage("pycon") self.mainText = Label() self.mainText.Parent = self self.mainText.AutoSize = True self.mainText.Location = Point(12, 12); self.mainText.Text = ("Tabbed Image Viewer\r\n\r\nWritten for PyCon 2007\r\n" "Using IronPython and Windows Forms\r\n\r\nBy:") self.addNameLabel("Andrzej Krzywda", "andrzej", Point(36, 90)) self.addNameLabel("Christian Muirhead", "christian", Point(36, 105)) self.addNameLabel("Michael Foord", "michael", Point(36, 120)) versionLabel = Label() versionLabel.Parent = self versionLabel.AutoSize = True versionLabel.Location = Point(12, 151) versionLabel.Text = "Version: " + __revision__ self.okButton = Button() self.okButton.Parent = self self.okButton.Text = "OK" self.okButton.Location = Point(251, 146) self.okButton.Click += self.onOK self.AcceptButton = self.okButton self.Text = "About" self.FormBorderStyle = FormBorderStyle.FixedDialog self.MinimizeBox = False self.MaximizeBox = False
def ShowDialog(self, controller, title, text): # set controller self.controller = controller # create confirmation boolean -- True means the user wants to save # the stimulus settings and stop the currently running stimulation. self.confirmation = False # create the form self.dialog_window = Form() self.dialog_window.AutoSize = True self.dialog_window.Width = 400 self.dialog_window.MaximumSize = Size(400, 225) self.dialog_window.StartPosition = FormStartPosition.CenterScreen self.dialog_window.Text = title self.dialog_window.FormBorderStyle = FormBorderStyle.FixedSingle # create the main panel self.panel = FlowLayoutPanel() self.panel.Parent = self.dialog_window self.panel.BackColor = DIALOG_COLOR self.panel.Dock = DockStyle.Top self.panel.Padding = Padding(10, 10, 0, 10) self.panel.FlowDirection = FlowDirection.TopDown self.panel.WrapContents = False self.panel.AutoSize = True self.panel.Font = BODY_FONT # add the dialog text dialog_label = Label() dialog_label.Parent = self.panel dialog_label.Text = text dialog_label.Width = self.panel.Width dialog_label.AutoSize = True dialog_label.Margin = Padding(0, 5, 0, 0) # add button panel self.add_button_panel() # show the dialog self.dialog_window.ShowDialog() # return the exp name return self.confirmation
def populate_stim_choice_panel(self): # empty stim choice panel list_of_controls = self.stim_choice_panel.Controls for control in list_of_controls: control.Dispose() self.stim_choice_panel.Controls.Clear() # add stim choice label stim_choice_label = Label() stim_choice_label.Parent = self.stim_choice_panel stim_choice_label.Text = "Stim:" stim_choice_label.AutoSize = True # add stim chooser self.stim_chooser = ComboBox() self.stim_chooser.DropDownStyle = ComboBoxStyle.DropDownList self.stim_chooser.Parent = self.stim_choice_panel self.stim_chooser.Items.AddRange(("Looming Dot", "Moving Dot", "Combined Dots", "Optomotor Grating", "Grating", "Broadband Grating", "Delay", "Black Flash", "White Flash")) ##!! need to add option for OKR here self.stim_chooser.SelectionChangeCommitted += self.on_stim_choice self.stim_chooser.Text = self.stim_type self.stim_chooser.Width = self.dialog_window.Width - 40 self.stim_chooser.AutoSize = True self.stim_chooser.Font = BODY_FONT
def __build_advancedtab(self): ''' builds and returns the "Advanced" Tab for the TabControl ''' tabpage = TabPage() tabpage.Text = i18n.get("ConfigFormAdvancedTab") # 1. --- a description label for this tabpage label = Label() label.UseMnemonic = False label.AutoSize = True label.Location = Point(14, 25) label.Size = Size(299, 17) label.Text = i18n.get("ConfigFormAdvancedText") # 2. --- build the update checklist (contains all the 'data' checkboxes) tbox = RichTextBox() tbox.Multiline=True tbox.MaxLength=65536 tbox.WordWrap = True tbox.Location = Point(15, 50) tbox.Size = Size(355, 200) menu = ContextMenu() items = menu.MenuItems items.Add( MenuItem(i18n.get("TextCut"), lambda s, ea : tbox.Cut() ) ) items.Add( MenuItem(i18n.get("TextCopy"), lambda s, ea : tbox.Copy() ) ) items.Add( MenuItem(i18n.get("TextPaste"), lambda s, ea : tbox.Paste() ) ) tbox.ContextMenu = menu self.__advanced_tbox = tbox # 3. --- add 'em all to the tabpage tabpage.Controls.Add(label) tabpage.Controls.Add(self.__advanced_tbox) return tabpage
import clr clr.AddReference('System.Windows.Forms') clr.AddReference('System.Drawing') from System.Windows.Forms import ( Application, Form, FormBorderStyle, Label ) from System.Drawing import ( Color, Font, FontStyle, Point ) form = Form() form.Text = "Hello World" form.FormBorderStyle = FormBorderStyle.Fixed3D form.Height = 150 newFont = Font("Verdana", 16, FontStyle.Bold | FontStyle.Italic) label = Label() label.AutoSize = True label.Text = "My Hello World Label" label.Font = newFont label.BackColor = Color.Aquamarine label.ForeColor = Color.DarkMagenta label.Location = Point(10, 50) form.Controls.Add(label) Application.Run(form)
def __init__(self): self.patient = patient self.Text = 'My Form' #title of the new format self.AutoSize = True labelX1 = Label() labelX2 = Label() labelX1.Text = 'What is' labelX2.Text = 'this?' labelX1.Location = Point(15, 28) labelX2.Location = Point(120, 28) labelX1.Width = 50 labelX2.Width = 50 labelX1.Height = 20 labelX2.Height = 40 self.Controls.Add(labelX1) self.Controls.Add(labelX2) # create a textbox property of the form self.textbox1 = TextBox() self.textbox1.Location = Point(50, 200) self.textbox1.Width = 120 self.textbox1.Height = 50 self.Controls.Add(self.textbox1) # implement an interaction button self.button1 = Button() self.button1.Text = "Auto-fill current patient name" self.button1.Location = Point(50, 120) self.button1.Width = 150 self.button1.Height = 45 self.Controls.Add(self.button1) self.button1.Click += self.button1_clicked # add checklist question self.question1 = Label() self.question1.Text = "Which actions have you finished so far?" self.question1.Location = Point(15, 280) self.question1.AutoSize = True self.Controls.Add(self.question1) # first checkbox self.check1 = CheckBox() self.check1.Text = "Patient modelling" self.check1.Location = Point(20, 310) self.check1.AutoSize = True self.check1.Checked = False self.Controls.Add(self.check1) self.check1.CheckedChanged += self.checkedChanged # second checkbox self.check2 = CheckBox() self.check2.Text = "Plan design" self.check2.Location = Point(20, 340) self.check2.AutoSize = True self.check2.Checked = False self.Controls.Add(self.check2) self.check2.CheckedChanged += self.checkedChanged # add checklist response message self.response1 = Label() self.response1.Text = "-" self.response1.Location = Point(160, 340) self.response1.AutoSize = True self.Controls.Add(self.response1) # generate combobox self.question2 = Label() self.question2.Text = "Select an ROI" self.question2.Location = Point(320, 310) self.question2.AutoSize = True self.Controls.Add(self.question2) rois = [r.Name for r in patient.PatientModel.RegionsOfInterest] self.combobox = ComboBox() self.combobox.Location = Point(320, 340) self.combobox.DataSource = rois self.Controls.Add(self.combobox) self.combobox.SelectionChangeCommitted += self.comboSelection # generate combobox response self.response2 = Label() self.response2.Text = "" self.response2.Location = Point(320, 380) self.response2.AutoSize = True self.Controls.Add(self.response2)
count = 0 def clicked(sender, args): global count global button count += 1 button.Text = "Clicked %s times" % count a = Form() a.Text = "Hi" a.Name = "Hi" label = Label() label.Text = "lel" label.Location = Point(50, 50) label.Height = 30 label.Width = 200 a.Controls.Add(label) button = Button() button.Text = "yeman" button.Location = Point(100, 100) button.Height = 30 button.Width = 50 button.Click += clicked a.Controls.Add(button) Application.Run(a)
if isinstance(IN[0], list): inputnames = IN[0] else: inputnames = [IN[0]] if isinstance(IN[1], list): inputtypes = IN[1] else: inputtypes = [IN[1]] for i, j in zip(inputnames, inputtypes): label = Label() label.Location = Point(xlabel, y + 4 * resfactY) label.Height = 20 * resfactY label.Width = 80 * resfactX label.Text = str(i) form.Controls.Add(label) if isinstance(j, list): cb = ComboBox() cb.Location = Point(xinput, y) cb.Width = 150 * resfactX globals()['dict%d' % (cbindex)] = {} try: for k in j: globals()['dict%d' % (cbindex)][k.Name] = k cb.Items.Add(k.Name) except: for k in j: try: globals()['dict%d' % (cbindex)][str(k)] = k except:
def __init__(self): self.patient = patient self.Text = 'My Form' #title of the new format self.AutoSize = True labelX1 = Label() labelX2 = Label() labelX1.Text = 'What is' labelX2.Text = 'this?' labelX1.Location = Point(15,28) labelX2.Location = Point(120,28) labelX1.Width = 50 labelX2.Width = 50 labelX1.Height = 20 labelX2.Height = 40 self.Controls.Add(labelX1) self.Controls.Add(labelX2) # create a textbox property of the form self.textbox1 = TextBox() self.textbox1.Location = Point(50,200) self.textbox1.Width = 120 self.textbox1.Height = 50 self.Controls.Add(self.textbox1) # implement an interaction button self.button1 = Button() self.button1.Text = "Auto-fill current patient name" self.button1.Location = Point(50, 120) self.button1.Width = 150 self.button1.Height = 45 self.Controls.Add(self.button1) self.button1.Click += self.button1_clicked # add checklist question self.question1 = Label() self.question1.Text = "Which actions have you finished so far?" self.question1.Location = Point(15,280) self.question1.AutoSize = True self.Controls.Add(self.question1) # first checkbox self.check1 = CheckBox() self.check1.Text = "Patient modelling" self.check1.Location = Point(20,310) self.check1.AutoSize = True self.check1.Checked = False self.Controls.Add(self.check1) self.check1.CheckedChanged += self.checkedChanged # second checkbox self.check2 = CheckBox() self.check2.Text = "Plan design" self.check2.Location = Point(20,340) self.check2.AutoSize = True self.check2.Checked = False self.Controls.Add(self.check2) self.check2.CheckedChanged += self.checkedChanged # add checklist response message self.response1 = Label() self.response1.Text = "-" self.response1.Location = Point(160,340) self.response1.AutoSize = True self.Controls.Add(self.response1) # generate combobox self.question2 = Label() self.question2.Text = "Select an ROI" self.question2.Location = Point(320,310) self.question2.AutoSize = True self.Controls.Add(self.question2) rois = [r.Name for r in patient.PatientModel.RegionsOfInterest] self.combobox = ComboBox() self.combobox.Location = Point(320,340) self.combobox.DataSource = rois self.Controls.Add(self.combobox) self.combobox.SelectionChangeCommitted += self.comboSelection # generate combobox response self.response2 = Label() self.response2.Text = "" self.response2.Location = Point(320,380) self.response2.AutoSize = True self.Controls.Add(self.response2)
def __build_behaviourtab(self): ''' builds and returns the "Behaviour" Tab for the TabControl ''' tabpage = TabPage() tabpage.Text = i18n.get("ConfigFormBehaviourTab") # 1. --- build the 'When scraping for the first time' label first_scrape_label = Label() first_scrape_label.AutoSize = False first_scrape_label.FlatStyle = FlatStyle.System first_scrape_label.Location = Point(52, 27) first_scrape_label.Text = i18n.get("ConfigFormFirstScrapeLabel") first_scrape_label.Size = Size(300, 17) # 1. --- build the 'autochoose series' checkbox self.__autochoose_series_cb = CheckBox() self.__autochoose_series_cb.AutoSize = False self.__autochoose_series_cb.FlatStyle = FlatStyle.System self.__autochoose_series_cb.Location = Point(82, 45) self.__autochoose_series_cb.Size = Size(300, 34) self.__autochoose_series_cb.Text =i18n.get("ConfigFormAutochooseSeriesCB") self.__autochoose_series_cb.CheckedChanged += self.__fired_update_gui # 2. --- build the 'confirm issue' checkbox self.__confirm_issue_cb = CheckBox() self.__confirm_issue_cb.AutoSize = False self.__confirm_issue_cb.FlatStyle = FlatStyle.System self.__confirm_issue_cb.Location = Point(82, 75) self.__confirm_issue_cb.Size = Size(300, 34) self.__confirm_issue_cb.Text = i18n.get("ConfigFormConfirmIssueCB") self.__confirm_issue_cb.CheckedChanged += self.__fired_update_gui # 3. -- build the 'use fast rescrape' checkbox self.__fast_rescrape_cb = CheckBox() self.__fast_rescrape_cb.AutoSize = False self.__fast_rescrape_cb.FlatStyle = FlatStyle.System self.__fast_rescrape_cb.Location = Point(52, 116) self.__fast_rescrape_cb.Size = Size(300, 34) self.__fast_rescrape_cb.Text = i18n.get("ConfigFormRescrapeCB") self.__fast_rescrape_cb.CheckedChanged += self.__fired_update_gui # 4. -- build the 'add rescrape hints to notes' checkbox self.__rescrape_notes_cb = CheckBox() self.__rescrape_notes_cb.AutoSize = False self.__rescrape_notes_cb.FlatStyle = FlatStyle.System self.__rescrape_notes_cb.Location = Point(82, 151) self.__rescrape_notes_cb.Size = Size(270, 17) self.__rescrape_notes_cb.Text = i18n.get("ConfigFormRescrapeNotesCB") self.__rescrape_notes_cb.CheckedChanged += self.__fired_update_gui # 5. -- build the 'add rescrape hints to tags' checkbox self.__rescrape_tags_cb = CheckBox() self.__rescrape_tags_cb.AutoSize = False self.__rescrape_tags_cb.FlatStyle = FlatStyle.System self.__rescrape_tags_cb.Location = Point(82, 181) self.__rescrape_tags_cb.Size = Size(270, 17) self.__rescrape_tags_cb.Text = i18n.get("ConfigFormRescrapeTagsCB") self.__rescrape_tags_cb.CheckedChanged += self.__fired_update_gui # 6. --- build the 'specify series name' checkbox self.__summary_dialog_cb = CheckBox() self.__summary_dialog_cb.AutoSize = False self.__summary_dialog_cb.FlatStyle = FlatStyle.System self.__summary_dialog_cb.Location = Point(52, 214) self.__summary_dialog_cb.Size = Size(300, 34) self.__summary_dialog_cb.Text = i18n.get("ConfigFormShowSummaryCB") self.__summary_dialog_cb.CheckedChanged += self.__fired_update_gui # 7. --- add 'em all to the tabpage tabpage.Controls.Add(first_scrape_label) tabpage.Controls.Add(self.__autochoose_series_cb) tabpage.Controls.Add(self.__confirm_issue_cb) tabpage.Controls.Add(self.__fast_rescrape_cb) tabpage.Controls.Add(self.__rescrape_tags_cb) tabpage.Controls.Add(self.__rescrape_notes_cb) tabpage.Controls.Add(self.__summary_dialog_cb) return tabpage
def __build_detailstab(self): ''' builds and returns the "Details" Tab for the TabControl ''' tabpage = TabPage() tabpage.Text = i18n.get("ConfigFormDetailsTab") tabpage.Name = "details" # 1. --- a description label for this tabpage label = Label() label.UseMnemonic = False label.AutoSize = True label.Location = Point(14, 35) label.Size = Size(299, 17) label.Text = i18n.get("ConfigFormDetailsText") # 2. --- the 'select all' button checkall_button = Button() checkall_button.Click += self.__fired_checkall checkall_button.Location = Point(280, 107) checkall_button.Size = Size(100, 23) checkall_button.Text = i18n.get("ConfigFormDetailsAll") # 3. --- the 'deselect all' button uncheckall_button = Button() uncheckall_button.Click += self.__fired_uncheckall uncheckall_button.Location = Point(280, 138) uncheckall_button.Size = Size(100, 23) uncheckall_button.Text = i18n.get("ConfigFormDetailsNone") # 4. --- build the update checklist (contains all the 'data' checkboxes) self.__update_checklist = CheckedListBox() self.__update_checklist.CheckOnClick = True self.__update_checklist.ColumnWidth = 125 self.__update_checklist.ThreeDCheckBoxes = True self.__update_checklist.Location = Point(15, 65) self.__update_checklist.MultiColumn = True self.__update_checklist.SelectionMode = SelectionMode.One self.__update_checklist.Size = Size(260, 170) self.__update_checklist.ItemCheck += self.__fired_update_gui self.__update_checklist.Items.Add(ConfigForm.__SERIES_CB) self.__update_checklist.Items.Add(ConfigForm.__VOLUME_CB) self.__update_checklist.Items.Add(ConfigForm.__NUMBER_CB) self.__update_checklist.Items.Add(ConfigForm.__TITLE_CB) self.__update_checklist.Items.Add(ConfigForm.__PUBLISHED_CB) self.__update_checklist.Items.Add(ConfigForm.__RELEASED_CB) self.__update_checklist.Items.Add(ConfigForm.__CROSSOVERS_CB) self.__update_checklist.Items.Add(ConfigForm.__PUBLISHER_CB) self.__update_checklist.Items.Add(ConfigForm.__IMPRINT_CB) self.__update_checklist.Items.Add(ConfigForm.__WRITER_CB) self.__update_checklist.Items.Add(ConfigForm.__PENCILLER_CB) self.__update_checklist.Items.Add(ConfigForm.__INKER_CB) self.__update_checklist.Items.Add(ConfigForm.__COLORIST_CB) self.__update_checklist.Items.Add(ConfigForm.__LETTERER_CB) self.__update_checklist.Items.Add(ConfigForm.__COVER_ARTIST_CB) self.__update_checklist.Items.Add(ConfigForm.__EDITOR_CB) self.__update_checklist.Items.Add(ConfigForm.__SUMMARY_CB) self.__update_checklist.Items.Add(ConfigForm.__CHARACTERS_CB) self.__update_checklist.Items.Add(ConfigForm.__TEAMS_CB) self.__update_checklist.Items.Add(ConfigForm.__LOCATIONS_CB) self.__update_checklist.Items.Add(ConfigForm.__WEBPAGE_CB) # 5. --- add 'em all to this tabpage tabpage.Controls.Add(label) tabpage.Controls.Add(checkall_button) tabpage.Controls.Add(uncheckall_button) tabpage.Controls.Add(self.__update_checklist) return tabpage
def __init__(self): FORMheight = 250 FORMwidth = 400 self.Text = 'Whatsapp Import - Whatsapp messages loader' self.Height = FORMheight-50 self.Width = FORMwidth flowPanel = FlowLayoutPanel() flowPanel.AutoSize = True flowPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink self.Controls.Add(flowPanel) labelDir = Label() labelDir.Text = "Exported artifacts directory path:" labelDir.Top = 20 labelDir.Left = 10 labelDir.Width = 300 labelDir.Anchor = AnchorStyles.Top TextboxDir = TextBox() TextboxDir.Name = 'ImportDir' TextboxDir.Text = '\export'#[type directory]' TextboxDir.Top = 45 TextboxDir.Left = 10 TextboxDir.Width = 360 TextboxDir.Anchor = AnchorStyles.Top '''labelRegex = Label() labelRegex.Text = "Chat file's name regex:" labelRegex.Top = 75 labelRegex.Left = 10 labelRegex.Width = 300 labelRegex.Anchor = AnchorStyles.Top fileRegex = TextBox() fileRegex.Name = 'fileNameRegex' fileRegex.Text = '^Conversa\sdo\sWhatsApp\scom\s(.*)\.txt$' fileRegex.Top = 100 fileRegex.Left = 10 fileRegex.Width = 360 fileRegex.Anchor = AnchorStyles.Top''' '''SelectDirBtn = Button() SelectDirBtn.Text = 'Select dir.' SelectDirBtn.Width = 150 SelectDirBtn.Top = 80 SelectDirBtn.Left = 350 SelectDirBtn.UseVisualStyleBackColor = True SelectDirBtn.Anchor = AnchorStyles.Top SelectDirBtn.Click += self.onClick''' button = Button() button.Text = "Import" button.Width = 110 button.Top = 120 button.Left = (FORMwidth / 2) - 50 button.Anchor = AnchorStyles.Top button.Click += self.buttonPressed self.Controls.Add(labelDir) self.Controls.Add(TextboxDir) #self.Controls.Add(labelRegex) #self.Controls.Add(fileRegex) #self.Controls.Add(SelectDirBtn) self.Controls.Add(button)
def __build_behaviourtab(self): ''' builds and returns the "Behaviour" Tab for the TabControl ''' tabpage = TabPage() tabpage.Text = i18n.get("ConfigFormBehaviourTab") # 1. --- build the 'When scraping for the first time' label first_scrape_label = Label() first_scrape_label.AutoSize = False first_scrape_label.FlatStyle = FlatStyle.System first_scrape_label.Location = Point(52, 27) first_scrape_label.Text = i18n.get("ConfigFormFirstScrapeLabel") first_scrape_label.Size = Size(300, 17) # 1. --- build the 'autochoose series' checkbox self.__autochoose_series_cb = CheckBox() self.__autochoose_series_cb.AutoSize = False self.__autochoose_series_cb.FlatStyle = FlatStyle.System self.__autochoose_series_cb.Location = Point(82, 45) self.__autochoose_series_cb.Size = Size(300, 34) self.__autochoose_series_cb.Text = i18n.get( "ConfigFormAutochooseSeriesCB") self.__autochoose_series_cb.CheckedChanged += self.__fired_update_gui # 2. --- build the 'confirm issue' checkbox self.__confirm_issue_cb = CheckBox() self.__confirm_issue_cb.AutoSize = False self.__confirm_issue_cb.FlatStyle = FlatStyle.System self.__confirm_issue_cb.Location = Point(82, 75) self.__confirm_issue_cb.Size = Size(300, 34) self.__confirm_issue_cb.Text = i18n.get("ConfigFormConfirmIssueCB") self.__confirm_issue_cb.CheckedChanged += self.__fired_update_gui # 3. -- build the 'use fast rescrape' checkbox self.__fast_rescrape_cb = CheckBox() self.__fast_rescrape_cb.AutoSize = False self.__fast_rescrape_cb.FlatStyle = FlatStyle.System self.__fast_rescrape_cb.Location = Point(52, 116) self.__fast_rescrape_cb.Size = Size(300, 34) self.__fast_rescrape_cb.Text = i18n.get("ConfigFormRescrapeCB") self.__fast_rescrape_cb.CheckedChanged += self.__fired_update_gui # 4. -- build the 'add rescrape hints to notes' checkbox self.__rescrape_notes_cb = CheckBox() self.__rescrape_notes_cb.AutoSize = False self.__rescrape_notes_cb.FlatStyle = FlatStyle.System self.__rescrape_notes_cb.Location = Point(82, 151) self.__rescrape_notes_cb.Size = Size(270, 17) self.__rescrape_notes_cb.Text = i18n.get("ConfigFormRescrapeNotesCB") self.__rescrape_notes_cb.CheckedChanged += self.__fired_update_gui # 5. -- build the 'add rescrape hints to tags' checkbox self.__rescrape_tags_cb = CheckBox() self.__rescrape_tags_cb.AutoSize = False self.__rescrape_tags_cb.FlatStyle = FlatStyle.System self.__rescrape_tags_cb.Location = Point(82, 181) self.__rescrape_tags_cb.Size = Size(270, 17) self.__rescrape_tags_cb.Text = i18n.get("ConfigFormRescrapeTagsCB") self.__rescrape_tags_cb.CheckedChanged += self.__fired_update_gui # 6. --- build the 'specify series name' checkbox self.__summary_dialog_cb = CheckBox() self.__summary_dialog_cb.AutoSize = False self.__summary_dialog_cb.FlatStyle = FlatStyle.System self.__summary_dialog_cb.Location = Point(52, 214) self.__summary_dialog_cb.Size = Size(300, 34) self.__summary_dialog_cb.Text = i18n.get("ConfigFormShowSummaryCB") self.__summary_dialog_cb.CheckedChanged += self.__fired_update_gui # 7. --- add 'em all to the tabpage tabpage.Controls.Add(first_scrape_label) tabpage.Controls.Add(self.__autochoose_series_cb) tabpage.Controls.Add(self.__confirm_issue_cb) tabpage.Controls.Add(self.__fast_rescrape_cb) tabpage.Controls.Add(self.__rescrape_tags_cb) tabpage.Controls.Add(self.__rescrape_notes_cb) tabpage.Controls.Add(self.__summary_dialog_cb) return tabpage
import clr clr.AddReference('System.Windows.Forms') clr.AddReference('System.Drawing') from System.Windows.Forms import (Application, Form, FormBorderStyle, Label) from System.Drawing import (Color, Font, FontStyle, Point) form = Form() form.Text = "Hello World" form.FormBorderStyle = FormBorderStyle.Fixed3D form.Height = 150 newFont = Font("Verdana", 16, FontStyle.Bold | FontStyle.Italic) label = Label() label.AutoSize = True label.Text = "My Hello World Label" label.Location = Point(10, 50) label.BackColor = Color.Aquamarine label.ForeColor = Color.DarkMagenta label.Font = newFont form.Controls.Add(label) Application.Run(form)