Comments (1)
Hello, husnih
Sorry for the delay, I have some work to do.
In code, you can manupulate as you like the widgets you defined and configured with pygubu-designer.
To do so, you mus get the widget instance using the builder method _get_object(widget_id)_.
Once you do that, you can call any method for that widget.
For example to add data into a treeview widget you use the _insert()_ method off the treeview instance.
A quick example:
#!/usr/bin/env python3
import tkinter as tk
import random
import pygubu
class MyApplication:
def __init__(self, master):
self.builder = builder = pygubu.Builder()
builder.add_from_file("treeview.ui")
# Create first the main window:
mainwindow = builder.get_object('mainwindow', master)
# Get the treeview instance
tree = builder.get_object('treeview')
# Populate treeview
for i in range(0, 6):
label = 'Level {0}'.format(i)
column_data = (random.randint(0, 1000), random.randint(0, 100))
itemid = tree.insert('', tk.END, text=label, values=column_data)
for j in range(0, 4):
label = 'Item {0}'.format(j)
column_data = (random.randint(0, 1000), random.randint(0, 100))
tree.insert(itemid, tk.END, text=label, values=column_data)
if __name__ == '__main__':
root = tk.Tk()
app = MyApplication(root)
root.mainloop()
The ui file:
<?xml version='1.0' encoding='utf-8'?>
<interface>
<object class="ttk.Frame" id="mainwindow">
<property name="height">250</property>
<property name="width">250</property>
<layout>
<property name="column">0</property>
<property name="propagate">True</property>
<property name="row">0</property>
<property name="sticky">nesw</property>
<rows>
<row id="0">
<property name="weight">1</property>
</row>
</rows>
<columns>
<column id="0">
<property name="weight">1</property>
</column>
</columns>
</layout>
<child>
<object class="pygubu.builder.widgets.scrollbarhelper" id="scrollbarhelper_1">
<property name="scrolltype">both</property>
<layout>
<property name="column">0</property>
<property name="propagate">True</property>
<property name="row">0</property>
<property name="sticky">nswe</property>
</layout>
<child>
<object class="ttk.Treeview" id="treeview">
<layout>
<property name="column">0</property>
<property name="propagate">True</property>
<property name="row">0</property>
<property name="sticky">nswe</property>
</layout>
<child>
<object class="ttk.Treeview.Column" id="treecolumn">
<property name="column_anchor">w</property>
<property name="command">on_treecolumn_click</property>
<property name="heading_anchor">w</property>
<property name="stretch">True</property>
<property name="text" translatable="yes">Tree</property>
<property name="tree_column">True</property>
<property name="visible">True</property>
</object>
</child>
<child>
<object class="ttk.Treeview.Column" id="column1">
<property name="column_anchor">w</property>
<property name="heading_anchor">center</property>
<property name="stretch">False</property>
<property name="text" translatable="yes">Column 1</property>
<property name="tree_column">False</property>
<property name="visible">True</property>
</object>
</child>
<child>
<object class="ttk.Treeview.Column" id="column2">
<property name="column_anchor">w</property>
<property name="heading_anchor">w</property>
<property name="stretch">True</property>
<property name="text" translatable="yes">Column 2</property>
<property name="tree_column">False</property>
<property name="visible">true</property>
<property name="width">333</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>
For more docs about tkinter widgets methods you can see this: http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/index.html
from pygubu.
Related Issues (20)
- Run executable file by pyinstaller generated, the erroe showed “ModuleNotFoundError: No module named 'Notebook'” HOT 7
- My picture won't load HOT 3
- i want to change text color with a funtion but it doesn't work HOT 2
- no module pygubu on m1 Macbook Pro HOT 3
- Trying to run functions from other classes on XML file HOT 1
- class name HOT 3
- Can I move all widgets assigned to a row down one row? HOT 3
- Tag Issue when packaging HOT 2
- Enhancement suggestion for pathchooserwidget
- Address editabletreeview directly :enhancement: HOT 5
- Bindings callbacks with underscore are not called HOT 2
- Allow to setup values for option database after first window created.
- The environment of Python 3.11 is externally managed by default. HOT 4
- TkScrolledFrame.configure() doesn't return
- CRITICAL BUG: AttributeError: module 'pygubu' has no attribute 'Builder' HOT 2
- All widgets show no appearance or layout properties.
- The anchor property does not function when defined in xml HOT 2
- Not all CTk arguments are exposed by pugubu HOT 1
- Scrolled frame doesn't resize in grid layout HOT 3
- Not a bug, just advising that the 'Glade' link is dead at the start if the README.md, and providing new URL HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pygubu.