Extends and simplifies tkinter functionality with built-in QoL improvements.
Project description
generalgui
Extends and simplifies tkinter functionality with built-in QoL improvements.
- Makes tkinter easy to use with some built-in QoL improvements.
- Built on top of tkinter, intended to extend features.
- Three main parts: App, Page and Element.
- Cannot partially use generalgui, everything has to be from here or nothing.
Installation
pip install generalgui
Usage example
Simple Button
from generalgui import App, Page, Button
btn = Button(Page(App(), pack=True), "Click me", lambda: btn.setValue("Changed value"))
btn.show()
Spreadsheet
from generalgui import App, Page, Spreadsheet
import pandas as pd
import random
df = pd.DataFrame([[random.randint(-100, 100) for _ in range(20)] for _ in range(20)])
page = Page(App())
Spreadsheet(page, cellVSB=True).loadDataFrame(df)
page.show()
Parts
App
Main part. Controls everything. Tk is 'widget' attribute.
Page
Middle part, controls Frame (and Canvas if scrollable).
Has no 'widget'. getBaseWidget() / getTopWidget().
Contains any amount of Elements and Pages.
Can be subclassed to create pre-built pages easily.
Has to be packed manually.
Element
Smallest part, controls widget.
Tkinter widget is 'widget' attribute.
Packed automatically because it always has to be inside a page.
Guidelines
-
An Element always controls one widget. It also has the same name as the tkinter widget it's controlling.
-
A tkinter widget only has .element attribute.
-
Always use an Element's method if you can, otherwise you can always access element.widget to use tkinter directly.
-
.parentPage attribute in Label goes to Page.
-
.parentPart attribute in Label goes to Page's Frame.
-
Every part has a .parentPage and .parentPart attribute.
-
Element can only be put inside a Page, not Frame, so create subpages if needed.
-
Elements are packed directly because they need a parent page.
-
Only have one method with the same name, even if it's shared. So no overriding.
Terms
Term | Meaning |
---|---|
Widget | A tkinter widget such as Label and Button. |
Part | An App, Page or Element from generalgui |
Attributes
. | .parentPage | .parentPart | .widget | .element |
---|---|---|---|---|
App | - | - | tk.Tk | - |
Page | Page or App | Frame or App | - | - |
Element | Page | Frame | tk.Label | - |
Widget | - | - | - | Element |
Todo
- Menu should probably inherit page so it becomes reuseable
- getElement(s)By* inspired by js
- Unique default style to distinguish my package from generic tkinter
- Automatic app and page creation
- Scale element / element.setSize()
- nan in spreadsheet becomes after saving then loading
- UnitTest for spreadsheet size syncs
- Make all parts visible by default
Features
- Easily make pages resizeable or scrollable.
- Styler which handles multiple stacked styles and automatically updates config.
- Lists all queued "after" functions and allows **kwargs when creating one.
- Entry: Ctrl+Del/Backspace to remove entire words.
- Entry: Press enter to press the next Button.
- Entry: Click outside Entry to remove selection.
- Right click anywhere to show a menu, propagates through elements to combine menus.
- Spreadsheet with optional locked headers and capable of loading and saving TSV files.
- ElementList which nicely stacks groups of buttons for example in a certain pattern.
- Combined Elements such as LabelEntry which easily allows you to get/set values.
- Default menu option to 'Rainbow' which colors all widgets in a random color for debugging.
- Propagating stackable binds through entire app, allows creating one bind for entire Page or App.
- Bind propagation options to stop propagation anywhere.
Elements
- Button
- Canvas
- Checkbutton
- Entry
- Frame
- Label
- OptionMenu
- Scrollbar
Combined Elements
- Grid(Page)
- Spreadsheet(Page: Grids)
- ElementList(Grid)
- InputList(ElementList)
- LabelCheckbutton(Page: Label and Checkbutton)
- LabelEntry(Page: Label and Entry)
Unsupported Elements
- Radiobutton
- Combobox
- Listbox
- SizeGrip
- Text
- Progressbar
- Scale
- Spinbox
- -Probably missing some
What's new
1.3.0
-
Made all binds go through App.
-
Which allows us to propagate events through parts.
-
Letting us for example bind an entire page.
-
Changed bindPropagation to just prevent propagating after part.
-
We can do that because we changed Button to use a tk.Label.
-
Silenced error for calling events on removed parts.
-
Made remove() iterate all children to set their 'removed' attribute to True.
-
Made hover and click style enable even if bound after init.
-
Silenced error for hiding resize element.
-
Tried fixing scroll page out of view, but failed so commented.
-
Made hideMultiline skip first spaces in line when hiding.
-
Made hideMultiline skip first empty lines.
-
Fixed multiline hiding for Label.
-
Also made it work in grid, although it doesn't preserve states, but it's probably fine.
-
Fixed issue with Styler where enabling an enabled style caused styles to stack. (Added to test)
-
Overrode Page.toggleMultilines() in Spreadsheet.toggleMultilines() to only call syncSizes() once.
-
Added toggleMultilines to Label and Page.
-
Added style for hiddenMultiline Labels.
-
Added 'recurrent' parameter to children methods.
-
Added 'add' parameter for menu().
-
Middle of toggleMultilines() for Page.
-
Solution for syncing spreadsheet sizes automatically.
-
Added spreadsheetSyncSizesWrappers for Element_Page.
-
Added hideMultiline to Page, which affects all Labels inside it.
-
Changed Label's hideMultiline parameter to default to it's parentPage.
-
Added a 'hideMultiline' option to Label.
-
Enabled this for all Labels in MainGrid in Spreadsheet.
-
Put all _sync functions in _syncSizes() and bound them to '' of MainGrid when df has been loaded.
-
Made spreadsheet prettier.
-
Changed default font to Consolas which is fixed-length and has no kerning. Aka monospace.
1.2.0
-
Alternating bg color in grid by default.
-
Left-align grid by default.
-
Enabled hover color for grid by default.
-
Added maximize().
-
Added setSize().
-
Added _syncRowKeysHeight to allow linebreak in a cell.
-
Added all getFirstPatternPos parameters to ElementList.
-
Fixed pixel alignments for spreadsheet.
-
Allowed Float for setSize().
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for generalgui-1.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fadea00eddca0f42b69dbce65beb1250f5778a74890a3e3c85e28adf4e787103 |
|
MD5 | 1dd837269834c33871b75de0fbad27b0 |
|
BLAKE2b-256 | c7b58c9a8d69d9576b84e499ef5aa4d95ef23589fdc1efd022c9bcdc7feed597 |