Esempio n. 1
0
 def init(self):
     box = PictureBox()
     box.Dock = DockStyle.Fill
     box.SizeMode = PictureBoxSizeMode.AutoSize
     box.Image = self.image
     self.image = box.Image
     self.Controls.Add(box)
     self.ClientSize = box.Size
Esempio n. 2
0
 def __init__(self, bitmap):
     Form.__init__(self)
     picBox  = PictureBox()
     picBox.SizeMode = PictureBoxSizeMode.AutoSize
     picBox.Image    = bitmap
     picBox.Dock     = DockStyle.Fill
     
     self.Controls.Add(picBox)
     self.Show()
     self.Width = bitmap.Width + 20
     self.Height = bitmap.Height + 20
Esempio n. 3
0
    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())
Esempio n. 4
0
    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())
Esempio n. 5
0
    def init(self):
        """Initialize the form.

        Returns
        -------
        None

        """
        box = PictureBox()
        box.Dock = DockStyle.Fill
        box.SizeMode = PictureBoxSizeMode.AutoSize
        box.Image = self.image
        self.image = box.Image
        self.Controls.Add(box)
        self.ClientSize = box.Size
Esempio n. 6
0
        def setup(self, filename, title):
            # adjust the form's client area size to the picture
            self.ClientSize = Size(300, 300)
            self.Text = title

            self.filename = filename
            self.image = Image.FromFile(self.filename)
            pictureBox = PictureBox()
            # this will fit the image to the form
            pictureBox.SizeMode = PictureBoxSizeMode.StretchImage
            pictureBox.Image = self.image
            # fit the picture box to the frame
            pictureBox.Dock = DockStyle.Fill

            self.Controls.Add(pictureBox)
            self.Show()
Esempio n. 7
0
        def setup(self, filename, title):
            # adjust the form's client area size to the picture
            self.ClientSize = Size(300, 300)
            self.Text = title

            self.filename = filename
            self.image = Image.FromFile(self.filename)
            pictureBox = PictureBox()
            # this will fit the image to the form
            pictureBox.SizeMode = PictureBoxSizeMode.StretchImage
            pictureBox.Image = self.image
            # fit the picture box to the frame
            pictureBox.Dock = DockStyle.Fill

            self.Controls.Add(pictureBox)
            self.Show()
Esempio n. 8
0
    def __build_gui(self):
        '''  Builds and initializes the gui for this panel '''

        # configure our image attribute objects
        cmap = ColorMap()
        cmap.OldColor = Color.White
        cmap.NewColor = Color.Gainsboro
        self.__normal_image_atts = ImageAttributes()
        self.__normal_image_atts.SetRemapTable(Array[ColorMap]([cmap]))
        self.__hovered_image_atts = ImageAttributes()

        # build our PictureBox
        self._picbox = PictureBox()
        self._picbox.SizeMode = PictureBoxSizeMode.StretchImage
        self._picbox.Location = Point(0, 0)
        self._picbox.Enabled = False
        self.Controls.Add(self._picbox)

        # set up our listeners
        self.Disposed += self.__disposed_fired
        self.Resize += self.__resize_fired
        self.MouseMove += self.__mouse_moved
        self.MouseLeave += self.__mouse_exited
        self._picbox.Paint += PaintEventHandler(self.__pbox_painted)

        # initialize ourself with a non-existent image
        self.set_image(None)
Esempio n. 9
0
 def free(self):
    ''' Explicitly frees all resources held by this object. '''
    self.__scheduler.shutdown(True) # blocks; safer even if gui locks a little
    self.__unknown_image.Dispose()
    self.__loading_image.Dispose()
    for image in self.__image_cache.values():
       image.Dispose()
    self.__image_cache = {}
    PictureBox.Dispose(self, True)
    def __init__(self):

        self.ClientSize = Size(350, 250)
        self.Text = "Dragging Images"
        self.Paint += self.OnPaint
    
        self.isDragging = False
        self.dropRect = Rectangle(10, 10, 200, 160)
        self.brush = Brushes.Gray
        picBox = PictureBox()

        self.loadImage()

        self.isDragging = False
        self.CenterToScreen()

        picBox.Parent = self
        picBox.Location = Point(100, 50)
        picBox.Size = Size(self.image.Width, self.image.Height)
        picBox.Image = self.image
        picBox.MouseDown += self.OnMousDown
        picBox.MouseUp += self.OnMousUp
        picBox.MouseMove += self.OnMousMove
        picBox.Cursor = Cursors.Hand
Esempio n. 11
0
#  EXPLORER INFO AREA CONTROLS ##########
ART_AREA = Panel()
ART_AREA.Width = EXPLORER_VISIBLE_INFORMATION_AREA.Width * 0.4
ART_AREA.Dock = DockStyle.Left

INFO_AREA = Panel()
INFO_AREA.Width = EXPLORER_VISIBLE_INFORMATION_AREA.Width * 0.6
INFO_AREA.Dock = DockStyle.Right
#INFO_AREA.BackColor = Color.Blue

EXPLORER_VISIBLE_INFORMATION_AREA.Controls.Add(ART_AREA)
EXPLORER_VISIBLE_INFORMATION_AREA.Controls.Add(INFO_AREA)
#########################################

#  ART AREA CONTROLS ####################
COVER_ART = PictureBox()
COVER_ART.SizeMode = PictureBoxSizeMode.StretchImage
#COVER_ART.Image = Bitmap(MemoryStream(WebClient().DownloadData('https://upload.wikimedia.org/wikipedia/en/2/2c/Metallica_-_Metallica_cover.jpg')))
#COVER_ART.Image = Bitmap(FileInterface(r'../test/Blackened.mp3').GetPicture)
COVER_ART.BackColor = Color.White
COVER_ART.Size = Size(160, 160)
COVER_ART.Top = 45
COVER_ART.Left = (ART_AREA.Width - COVER_ART.Width) / 2

ART_AREA.Controls.Add(COVER_ART)
#########################################

#  INFO AREA CONTROLS ###################

#  Construct four identical textboxes
#  Each Formbox is 40 units above the next
Esempio n. 12
0
    def draw(self, show=True, filename=None, update=False, usecoords=False):
        """Create a 2D depiction of the molecule.

        Optional parameters:
          show -- display on screen (default is True)
          filename -- write to file (default is None)
          update -- update the coordinates of the atoms to those
                    determined by the structure diagram generator
                    (default is False)
          usecoords -- don't calculate 2D coordinates, just use
                       the current coordinates (default is False)

        Tkinter and Python Imaging Library are required for image display.
        """
        if update:
            mol = self.Mol
        else:
            mol = self.Mol.clone()
        if not usecoords:
            mol.layout()
        if show or filename:
            renderer = IndigoRenderer(indigo)
            indigo.setOption("render-output-format", "png")
            indigo.setOption("render-margins", 10, 10)
            indigo.setOption("render-coloring", "True")
            indigo.setOption("render-image-size", 300, 300)
            indigo.setOption("render-background-color", "1.0, 1.0, 1.0")
            if self.title:
                indigo.setOption("render-comment", self.title)
            if filename:
                filedes = None
            else:
                filedes, filename = tempfile.mkstemp()

            renderer.renderToFile(mol, filename)

            if show:
                if sys.platform[:4] == "java":
                    image = javax.imageio.ImageIO.read(java.io.File(filename))
                    frame = javax.swing.JFrame(visible=1)
                    frame.getContentPane().add(
                        javax.swing.JLabel(javax.swing.ImageIcon(image)))
                    frame.setSize(300, 300)
                    frame.setDefaultCloseOperation(
                        javax.swing.WindowConstants.DISPOSE_ON_CLOSE)
                    frame.show()

                elif sys.platform[:3] == "cli":
                    if filedes:
                        errormessage = (
                            "It is only possible to show the molecule if you "
                            "provide a filename. The reason for this is that I kept "
                            "having problems when using temporary files.")
                        raise RuntimeError(errormessage)
                    form = Form()
                    form.ClientSize = Size(300, 300)
                    form.Text = self.title
                    image = Image.FromFile(filename)
                    box = PictureBox()
                    box.SizeMode = PictureBoxSizeMode.StretchImage
                    box.Image = image
                    box.Dock = DockStyle.Fill
                    form.Controls.Add(box)
                    form.Show()
                    Application.Run(form)

                else:
                    if not PILtk:
                        errormessage = (
                            "Tkinter or Python Imaging "
                            "Library not found, but is required for image "
                            "display. See installation instructions for "
                            "more information.")
                        raise ImportError(errormessage)

                    root = tk.Tk()
                    root.title((hasattr(self, "title") and self.title)
                               or self.__str__().rstrip())
                    frame = tk.Frame(root, colormap="new",
                                     visual='truecolor').pack()
                    image = PIL.open(filename)
                    imagedata = PILtk.PhotoImage(image)
                    label = tk.Label(frame, image=imagedata).pack()
                    quitbutton = tk.Button(
                        root, text="Close",
                        command=root.destroy).pack(fill=tk.X)
                    root.mainloop()

            if filedes:
                os.close(filedes)
                os.remove(filename)
Esempio n. 13
0
    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)
Esempio n. 14
0
    def draw(self, show=True, filename=None, update=False, usecoords=False):
        """Create a 2D depiction of the molecule.

        Optional parameters:
          show -- display on screen (default is True)
          filename -- write to file (default is None)
          update -- update the coordinates of the atoms to those
                    determined by the structure diagram generator
                    (default is False)
          usecoords -- don't calculate 2D coordinates, just use
                       the current coordinates (default is False)

        Tkinter and Python Imaging Library are required for image display.
        """
        if update:
            mol = self.Mol
        else:
            mol = self.Mol.clone()
        if not usecoords:
            mol.layout()
        if show or filename:
            renderer = IndigoRenderer(indigo)
            indigo.setOption("render-output-format", "png")
            indigo.setOption("render-margins", 10, 10)
            indigo.setOption("render-coloring", "True")
            indigo.setOption("render-image-size", 300, 300)
            indigo.setOption("render-background-color", "1.0, 1.0, 1.0")
            if self.title:
                indigo.setOption("render-comment", self.title)
            if filename:
                filedes = None
            else:
                filedes, filename = tempfile.mkstemp()

            renderer.renderToFile(mol, filename)

            if show:
                if sys.platform[:4] == "java":
                    image = javax.imageio.ImageIO.read(java.io.File(filename))
                    frame = javax.swing.JFrame(visible=1)
                    frame.getContentPane().add(javax.swing.JLabel(javax.swing.ImageIcon(image)))
                    frame.setSize(300,300)
                    frame.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE)
                    frame.show()

                elif sys.platform[:3] == "cli":
                    if filedes:
                        errormessage = ("It is only possible to show the molecule if you "
                                        "provide a filename. The reason for this is that I kept "
                                        "having problems when using temporary files.")
                        raise RuntimeError(errormessage)
                    form = Form()
                    form.ClientSize = Size(300, 300)
                    form.Text = self.title
                    image = Image.FromFile(filename)
                    box = PictureBox()
                    box.SizeMode = PictureBoxSizeMode.StretchImage
                    box.Image = image
                    box.Dock = DockStyle.Fill
                    form.Controls.Add(box)
                    form.Show()
                    Application.Run(form)

                else:
                    if not PILtk:
                        errormessage = ("Tkinter or Python Imaging "
                                        "Library not found, but is required for image "
                                        "display. See installation instructions for "
                                        "more information.")
                        raise ImportError, errormessage

                    root = tk.Tk()
                    root.title((hasattr(self, "title") and self.title)
                               or self.__str__().rstrip())
                    frame = tk.Frame(root, colormap="new", visual='truecolor').pack()
                    image = PIL.open(filename)
                    imagedata = PILtk.PhotoImage(image)
                    label = tk.Label(frame, image=imagedata).pack()
                    quitbutton = tk.Button(root, text="Close", command=root.destroy).pack(fill=tk.X)
                    root.mainloop()


            if filedes:
                os.close(filedes)
                os.remove(filename)
Esempio n. 15
0
    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()
Esempio n. 16
-1
 def _initialize(self):
    ''' Initial configuration for new instances of this class '''
    
    PictureBox.__init__(self)      
    def visibility_changed(sender, args):
       if self.Visible: self.__update_image()
       
    self.VisibleChanged += visibility_changed
    self.SizeMode = PictureBoxSizeMode.StretchImage
    self.set_image_ref(None)