PySimpleGUI / PySimpleGUI/PySimpleGUI

Resizing a button - second attempt

Open
#1,984 19 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
13.8k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

Type of Issues (Enhancement, Error, Bug, Question)

Question

Operating System

Linux - Mint18

Python version

3.6

PySimpleGUI Port and Version

4.1.0 - tkiner

Your Experience Levels In Months or Years

7_____ Python programming experience
15___ Programming experience overall
_yes Have used another Python GUI Framework (tkiner, Qt, etc) previously (yes/no is fine)?

You have completed these steps:
  • [ x] Read instructions on how to file an Issue
  • [ x] Searched through main docs http://www.PySimpleGUI.org for your problem
  • [ x] Searched through the readme for your specific port if not PySimpleGUI (Qt, WX, Remi)
  • [ x] Looked for Demo Programs that are similar to your goal http://www.PySimpleGUI.com
  • [ x] Note that there are also Demo Programs under each port on GitHub
  • [ x] Run your program outside of your debugger (from a command line)
  • [ x] Searched through Issues (open and closed) to see if already reported
Code or partial code causing the problem

I'm not into graphics much so maybe I have done something wrong. I created an image using Libreoffice Draw and saved it as a .png file. As you can see from the attached code the button is the size I want but the text is pushed down into the lower right corner. In the image it is centered.

import PySimpleGUI as sg
from PySimpleGUI import InputCombo, Combo, Multiline, ML, MLine, Checkbox, CB, Check, Button, B, Btn, \
    ButtonMenu, Canvas, Column, Col, Combo, Frame, Graph, Image, InputText, Input, In, Listbox, LBox,  \
    Menu, Multiline, ML, MLine, OptionMenu, Output, Pane, ProgressBar,  Radio, Slider, Spin, StatusBar, \
    Tab, TabGroup, Table, Text, Txt, T, Tree, TreeData,  VerticalSeparator, Window, Sizer

sg.change_look_and_feel('GreenTan')

copy2 = b'iVBORw0KGgoAAAANSUhEUgAAADIAAAAiCAYAAAFq7rq8AAAACXBIWXMAAA7GAAAOxgHq1c2SAAAJyUlEQVR4nM1YC3AV1Rn+9t6994YQMZBkTKEBykMIb6cpsZlp6oxQwNopI48OBcGCWnEQQysPnbY6tYVGhVFnqq2jUF4i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AAAElFTkSuQmCC'

col2 = Column([[Frame('Accounts:', [[Column([[Listbox(values=('test1', 'test2',
              'test3'), size=(50, 22), pad=(0, 0)), ]], size=(260, 404),
              pad=(0, 0))]], element_justification='center')]], pad=(0, 0))

col1 = Column([
    # Categories frame
    [Frame('Categories:', [[Radio('Websites', 'radio1', default=True,
     size=(9, 1)), Radio('Software', 'radio1', size=(8, 1))]],)],
    # Information frame
    [Frame(layout=[[Column([[Text('Account:', pad=(0, 0))],
                      [Input(size=(20, 1), pad=(0, 0))],
                      [Text('User Id:', pad=(0, 0))],
                      [Input(size=(20, 1), pad=(0, 0)), Button('', # 'Copy',
                            image_data=copy2,
                            # image_filename='copy4.png',
                            image_size=(50, 20),
                            # image_subsample=2,
                            # button_color=sg.TRANSPARENT_BUTTON,
                            key='-USERID-')],
                      [Text('Password:', pad=(0, 0))],
                      [Input(size=(20, 1), pad=(0, 0)), Button('Copy', key='-PASS-', font=('courier', 6))],
                      [Text('Location:', pad=(0, 0))],
                      [Input(size=(20, 1), pad=(0, 0)), Button('Copy', key='-LOC', font=('courier', 6))],
                      [Text('Notes:', pad=(0, 0))],
                      [Multiline(size=(18, 6))],
                      ], size=(200, 350), pad=(0, 0))]], title='Information:')], ], pad=(0, 0))

layout = [[col1, col2],
    # Actions Frame
    [Frame('Actions:', [[Column([[Button('Save'), Button('Clear'), Button('Delete'),
        ]], size=(524, 45), pad=(0,0))]])]]

# Position at top left side corner on right hand monitor
window = Window('Passwords', layout,location=(1924, 0))

while True:
    event, values = window.read()
    print(event, values)
    if event is None:
        break
window.close()

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the provided script with Python 3.6, PySimpleGUI 4.1.0, and the tkinter port on Linux Mint 18. Start by isolating the image-backed Button using the supplied image data and determine whether the text placement matches the reported behavior; done means the button retains its requested size while its label is centered.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.