Giter Site home page Giter Site logo

sandeep-gh / pysimplegui_ui_generator Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 163 KB

Generate different layout using PySimpleGui by changing few configuration parameters

Home Page: https://github.com/sandeep-gh/PySimpleGui_UI_generator/wiki

License: MIT License

Python 100.00%
pysimplegui python-ast pysimplegui-elements gui

pysimplegui_ui_generator's Introduction

PySimpleGui_UI_generator

Generate different layout using PySimpleGui by changing few configuration parameters

Introduction

The program allows to generate different layouts over the same basic PySimpleGui elements. GIF below shows randomly generate layouts that are generated by simple changing layout configuration parameters (see code)

Different layouts

Layout with 3 tables

3 tables layout

Layout template for a row

def text_gelem(): return Gelem(sg.Text,  sty={"auto_size_text": 'False',
                                              "size": (8, 4)
                                              })


row_gelems_t = [text_gelem(), text_gelem()]

A table structure generator from labels and suffixes

def atbl_li(labelgi, suffixgi):
    return BlockLI.bli(row_gelems_t, ('lc_', 'rc_',), labelgi,
                       CI(suffixgi, SI()), sframed=True, sstacked='V')  # add column id to suffix

Generate multiple tables

Make sure the table cells have different keys

def all_tbl_li(all_tbl_labels):
    return ListNodeLI([atbl_li(tbl_labels, TI(idx, 2)) for idx, tbl_labels in EI(all_tbl_labels)])
    

TI, EI, SI are simple utility iterator functions.

generate the layout from table entries

tli = all_tbl_li([[('t1r1c1', 't1r1c2'), ('t1r2c1', 't1r2c2'),  ('t1r3c1', 't1r3c2')],
                  [('t2r1c1', 't1r1c2'), ('t2r2c1', 't2r2c2'),  ('t2r3c1', 't2r3c2')],
                  [('t3r1c1', 't3r1c2'), ('t3r2c1', 't3r2c2'),  ('t3r3c1', 't3r3c2')]
                  ]
                 )

Display the layout

lg.set_li_layout(tli)
the_layout = lg.compose_layout_li(tli)
print(the_layout)

layout = []
exit_button_row = [[
    sg.Button('Exit')
]
]
layout = layout + [[the_layout]] + exit_button_row
window = sg.Window('PGAppAnalytics', layout)
while True:
    event, values = window.read()
    print("event pressed = ", event)
    if event == 'Exit':
        break
window.close()

#Usage

The code also generates code corresponding to all the gui elements. The generated code is basically function stubs. Generated code example shown below:

def on_button1a_click(event, appstate, /):
    pass

def on_button2a_click(event, appstate, /):
    print('app action on button2a')
    pass

def on_button1b_click(event, appstate, /):
    pass

def on_button2b_click(event, appstate, /):
    pass

def on_text1a_click(event, appstate, /):
    pass

def on_text1b_click(event, appstate, /):
    pass

def on_text2a_click(event, appstate, /):
    pass

def on_text2b_click(event, appstate, /):
    pass

Already generated or manually create function stubs are left as is.

pysimplegui_ui_generator's People

Contributors

sandeep-gh avatar

Stargazers

 avatar

Watchers

 avatar

pysimplegui_ui_generator's Issues

What was your project's target?

Interesting Repo! Intrigued as to why you would write this kind of program since it's not a particularly useful application on its own. Does seem like it would exercise the PySimpleGUI code in interesting ways. Was that the purpose? Testing?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.