Git Product home page Git Product logo

pygubu's Introduction

Build Status

Leer en Español

Welcome to Pygubu!

Pygubu is a RAD tool to enable quick and easy development of user interfaces for the Python's tkinter module.

The user interfaces designed are saved as XML files, and, by using the pygubu builder, these can be loaded by applications dynamically as needed.

Pygubu is inspired by Glade.

Installation

The latest version of pygubu requires Python >= 3.6

You can install pygubu using pip:

pip install pygubu

Usage

Since version 0.10 the project was splitted in two main modules:

  • The pygubu core (this project), that load and build user interfaces defined in xml.
  • The interface editor pygubu-designer, that helps you create the xml definition graphically.

Start creating your tkinter application xml UI definition using the pygubu-designer editor.

The following is a UI definition example called helloworld.ui:

<?xml version='1.0' encoding='utf-8'?>
<interface version="1.2">
  <object class="tk.Toplevel" id="mainwindow">
    <property name="height">200</property>
    <property name="resizable">both</property>
    <property name="title" translatable="yes">Hello World App</property>
    <property name="width">200</property>
    <child>
      <object class="ttk.Frame" id="mainframe">
        <property name="height">200</property>
        <property name="padding">20</property>
        <property name="width">200</property>
        <layout manager="pack">
          <property name="expand">true</property>
          <property name="side">top</property>
        </layout>
        <child>
          <object class="ttk.Label" id="label1">
            <property name="anchor">center</property>
            <property name="font">Helvetica 26</property>
            <property name="foreground">#0000b8</property>
            <property name="text" translatable="yes">Hello World !</property>
            <layout manager="pack">
              <property name="side">top</property>
            </layout>
          </object>
        </child>
      </object>
    </child>
  </object>
</interface>

Then, you should create your application script as shown below (helloworld.py):

# helloworld.py
import pathlib
import tkinter as tk
import tkinter.ttk as ttk
import pygubu

PROJECT_PATH = pathlib.Path(__file__).parent
PROJECT_UI = PROJECT_PATH / "helloworld.ui"


class HelloworldApp:
    def __init__(self, master=None):
        # 1: Create a builder and setup resources path (if you have images)
        self.builder = builder = pygubu.Builder()
        builder.add_resource_path(PROJECT_PATH)

        # 2: Load a ui file
        builder.add_from_file(PROJECT_UI)

        # 3: Create the mainwindow
        self.mainwindow = builder.get_object('mainwindow', master)

        # 4: Connect callbacks
        builder.connect_callbacks(self)

    def run(self):
        self.mainwindow.mainloop()


if __name__ == '__main__':
    app = HelloworldApp()
    app.run()

Note: instead of helloworld.ui, you should insert the filename (or full path) of your UI definition:

PROJECT_UI = PROJECT_PATH / "helloworld.ui"

Note: instead of 'mainwindow', you should have the name of your main_widget (the parent of all widgets) in the following line:

self.mainwindow = builder.get_object('_your_main_widget_')

Documentation

Visit the pygubu wiki for more documentation.

The following are some good tkinter (and tk) references:

You can also see the examples directory or watch this introductory video tutorial.

History

See the list of changes here.

pygubu's People

Contributors

ajasja avatar alejandroautalan avatar bloodyrain2k avatar danicotra avatar errmac avatar frainfreeze avatar gulart avatar gwelch-contegix avatar hucste avatar jrezai avatar larryw3i avatar llorc avatar majensen avatar microbullet avatar nbro avatar nuno-andre avatar orthographic-pedant avatar rdbende avatar ryaneverett33 avatar scls19fr avatar timgates42 avatar tkaluza avatar zaazbb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pygubu's Issues

Question on expanding a basic app

Hi,

I've made some progress now with the XML workaround, and I need to prompt the user to enter a password when the application launches. All the examples I can find on using tk.Entry assume you're building the whole thing in code, rather than loading the UI via pygubu.

Do you have any advice on the best way to add things like popups (text input, confirmation dialogues, etc.)? I presume it's OK to mix straight tk code in with the pygubu.TkApplication class?

Thanks,

David.

Selecting Widgets Causes Widget List to Creep Right

Clicking on a widget in the list of instantiated widgets (underneath "Widget Id, Class, R, C") causes the Widget List (with tk and ttk controls) to creep in size to the right.

Platform: Windows 7, Python 3.3

Reproduction steps:

  1. expand tk under Widget List
  2. expand Containers
  3. double click Frame
  4. Click on "Frame_#" underneath Widget Id, to select it.
  5. Keep clicking on it, just like in step 4. (In repetition)

Observed: Widget List pane gets wider and wider by one pixel with each click.
Expected: Widget List pane keeps the same width.

Issue with updating text in the TKText widget

Hello,
I have a tk.text widget that I need to update.
Right now the builder widget appends the text in the properties of the builderobject
From TKText
def _set_property(self, target_widget, pname, value):
if pname == 'text':
target_widget.insert('0.0', value)
else:
super(TKText, self)._set_property(target_widget, pname, value)

Anyway my work around (since my text is disabled - this probably needs to be a property so that it can be managed by the builder) was to:

    wgt.properties['text'] = text
    logger.debug("widget id %s type property %s", wgt.objectid, wgt.properties)
    #The pygubu tktext widget simply appends the text at the beginning of the 
    #line and doesn't allow text to be updated in a disabled widget
    wtext = wgt.widget
    wtext.config(state=tk.NORMAL)
    wtext.delete(1.0, tk.END)
    wtext.insert(tk.END, text)
    wtext.config(state=tk.DISABLED)

pygubu example with frame and menu ?

Hello,
I checked the examples,
BUT I failed to generate the well known standard GUI application on any platform which usually combine:

  • Frame ( "commands.ui" )
  • Menus at the top of the Frame ( "menuexample.ui" )

and I did not find any example in the examples folder.

Indeed pygubu offers with "commands.ui" an example how to put menus at any place on the screen, but I don´t see that I can generate the same effect as done do with your "menuexample.ui" and as I know from the SpecTcl Designer
http://www.sourceforge.net/projects/spectcl

I already tested to move around some of the XML code, but without positive effect.

May you, the developer or the users, help me :-)?! With a working project example?
Or are there techncial Python Tkinter constrains which prevent that ?! As I said, SpecTCL designer generates code which does it, so it must be possible but who know if in the Tkinter mode used here...

Sincerely
Rolf

How to set row weight?

for example, set the col 0 weight to 1, code as below:

frame.columnconfigure(0, weight=1)

how to do it in pygubu? I can not find the weight option.

install pygubu by pip, met a error

under winxp sp3, open the cmd.exe, input "pip install pygubu", met a error when installing pygubu.

Downloading/unpacking pygubu
  Running setup.py (path:c:\docume~1\jf\locals~1\temp\pip_build_jf\pygubu\setup.
py) egg_info for package pygubu

Installing collected packages: pygubu
  Running setup.py install for pygubu
    usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: -c --help [cmd1 cmd2 ...]
       or: -c --help-commands
       or: -c cmd --help

    error: option --single-version-externally-managed not recognized
    Complete output from command C:\Python33\python.exe -c "import setuptools, t
okenize;__file__='c:\\docume~1\\jf\\locals~1\\temp\\pip_build_jf\\pygubu\\setup.
py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n'
, '\n'), __file__, 'exec'))" install --record c:\docume~1\jf\locals~1\temp\pip-4
w66tl-record\install-record.txt --single-version-externally-managed --compile:
    usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]

   or: -c --help [cmd1 cmd2 ...]

   or: -c --help-commands

   or: -c cmd --help



error: option --single-version-externally-managed not recognized

----------------------------------------
Cleaning up...
Command C:\Python33\python.exe -c "import setuptools, tokenize;__file__='c:\\doc
ume~1\\jf\\locals~1\\temp\\pip_build_jf\\pygubu\\setup.py';exec(compile(getattr(
tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'
))" install --record c:\docume~1\jf\locals~1\temp\pip-4w66tl-record\install-reco
rd.txt --single-version-externally-managed --compile failed with error code 1 in
 c:\docume~1\jf\locals~1\temp\pip_build_jf\pygubu
Storing debug log for failure in C:\Documents and Settings\jf\pip\pip.log

ttkspinbox.py

Please change in ttkspinbox.py file:
import tkinter.ttk as ttk

to:
try:
import tkinter as tk
except:
import Tkinter as tk

Create startup file for Windows OS

zaazbb commented:
1- I am under winows xp sp3, i installed pygubu using "python setup.py install". "c:\Python3.x\Scripts\pygubu" is not runable on windows, I rename "c:\Python3.x\Scripts\pygubu" to "c:\Python3.x\Scripts\pygubu.py", it running corrently.

Created from comment #2 (comment)

New dialog widget

Hi - thanks again for your advice so far - I'm getting there slowly! I moved away from the helper class based on your example, and now have a progress dialog as well as the main app window. However, there are still a couple of things not right, and some errors from the designer.

Firstly, I can't seem to set the size of the dialog window - or maybe I'm not understanding how to do it. I've tried dragging the blue box in the designer, and it snaps back to the old size as soon as I do anything else (like change a property of one of the widgets on the dialog window). If I change the height or width in the General tab of the properties pane, I see an error in the console where I ran the designer from:

WARNING:pygubu.builderobject:Attempt to set an unknown property 'modal' on class '<class pygubudesigner.widgets.toplevelframe.ToplevelFramePreview at 0x01237DF8>'

I can add padding to the widgets on the dialog to make it grow a little, but that's all.

The other thing is more tkinter I suspect, but I can't get the order of initialising / creating / showing the windows to work properly. Is there a way to get the progress dialog displayed / updated without showing the mainWindow? It appears very large (not sure why - default width of treeview columns I suspect, which aren't set until the data is loaded and I know what width they need to be). It's also just an empty white box until the data is loaded...

Thanks again for your help and effort on pygubu - there's no way I'd have got this far without both!

2 files called pygubu = bad

If someone has "C:\Python34\Scripts" in their env PATH and then imports pygubu, it will import "C:\Python34\Scripts\pygubu". This results in the python script failing.

By changing pygubu in C:\Python34\Scripts\ to any other name this can be avoided.

I think cx_freeze adds "C:\Python34\Scripts" to PATH so this will be a problem for a lot of users.

edit: I've forked pygubu and added two corrections to fix this problem.

Previous open file overwriten

Steps to reproduce:
Open a ui file using File->Open, example: myapp.ui
Click File->New to create a new empty project.
Click File->Save, the previously opened file is overwriten.

Not able to resize scrolled frame

if text box is wrapped inside pygubu.builder.widgets.scrolledframe, scrolled frame takes a initial position and not able to resize the frame

image

Configured images are not shown in preview when file is opened later.

Steps to reproduce:

1- Create a ui file, add widgets, and configure image properties. The images are shown in the preview correctly.
2- Save the project file to example.ui
3- Close and reopen the designer and open example.ui again. The configured images are not shown in the preview.

Expected result:
Configured images should be visible in the preview at least for images located in a directory relative to the example.ui directory

AttributeError

Hello,

I just downloaded and tried to run pygubu but it does nothing when called pygubu or pygubu.pyw and when I try pygubu.pyc it returns an AttributeError.

D:\Python27\Scripts>pygubu

D:\Python27\Scripts>pygubu.pyw

D:\Python27\Scripts>pygubu.pyc
Running Python sys.version_info(major=2, minor=7, micro=3, releaselevel='final',
serial=0) on 'win32'
Running Python sys.version_info(major=2, minor=7, micro=3, releaselevel='final',
serial=0) on 'win32'
Traceback (most recent call last):
File "D:\Python27\Scripts\pygubu.pyw", line 42, in
import pygubu
File "D:\Python27\Scripts\pygubu.pyw", line 43, in
print("Pygubu: v. %s" % (pygubu.version,))
AttributeError: 'module' object has no attribute 'version'

D:\Python27\Scripts>

Any ideias?

Thanks,

JM

Problem when trying to run the .ui application

I have used the code you are suggestion to run my "hello.ui" file, but it's not working, and raises the exception "raise Exception('Widget not defined.')" at line 322 of your init.py file under /builder.

This is my hello.ui:

<?xml version='1.0' encoding='utf-8'?>
<interface>
  <object class="ttk.Frame" id="Frame_1">
    <property name="height">200</property>
    <property name="width">200</property>
    <layout>
      <property name="column">0</property>
      <property name="propagate">True</property>
      <property name="row">0</property>
    </layout>
    <child>
      <object class="ttk.Button" id="Button_1">
        <property name="text" translatable="yes">Button_1</property>
        <layout>
          <property name="column">0</property>
          <property name="propagate">True</property>
          <property name="row">0</property>
        </layout>
      </object>
    </child>
  </object>
</interface>

This is the code I am using to run the "hello.ui"

#test.py
import tkinter as tk
import pygubu

class Application:
    def __init__(self, master):

        #1: Create a builder
        self.builder = builder = pygubu.Builder()

        #2: Load an ui file
        builder.add_from_file('hello.ui')

        #3: Create the widget using a master as parent
        self.mainwindow = builder.get_object('mainwindow', master)


if __name__ == '__main__':
    root = tk.Tk()
    app = Application(root)
    root.mainloop()

I am running the application from the main folder of the project. I had also some problems in running the builder/designer, until I did not find the script under /bin in this github repository. I think you should clarify better how to run the builder/designer in your README file.

My OS is Darwin.

Apart from this, would be possible to contribute with my help to this project?

I was thinking also in developing something similar, but my knowledge of tkinter is still not so good, but I would like starting helping you in this project, of course if you don't mind.

If it's ok, it would be great if you could tell me more in details how can I understand better your application, how can study it further, how did you structure the project, so that I am also able to navigate through it without any problems.

A UnicodeDecodeError occurrented, when adding new i18n local language .

Environment: python3.3.2, windows xp sp3.
Operation steps:
1> download "pygubu / po / pygubu.pot" on github.com, and add chinese translations.
2> create "pygubu.mo" use "C:\Python33\Tools\i18n\msgfmt.py" script.
3> move "pygubu.mo" to "C:\Python33\Lib\site-packages\pygubudesigner\locale\zh_CN\LC_MESSAGES" dir.
4> run "C:\Python33\Scripts\pygubu.py", and met a error "UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 0: ordinal not in range(128)"

ps: my language code is "zh_CN".

>>> import os
>>> os.environ.get('LANG', '')
'zh_CN'
>>> import locale
>>> locale.getdefaultlocale()
('zh_CN', 'cp936')
>>> 

Problem loading .ui on Win32

I've just started with tk on Win32, and having a hard time creating a UI from scratch, searched for a builder. pygubu is by far the best of anything I've found, but I can't seem to follow a basic cycle of build, load, display.

My UI will need data, so I added a ttkFrame, ttkTreeview, 2 ttk.Treeview.Column s and a ttk.Button. On saving the .ui and loading it via the simple Application framework here: https://github.com/alejandroautalan/pygubu/wiki/Make-widget-resizable, I get the following error. It looks like it might be to do with whitespace in the XML not being stripped away. Is this a new user error, or something worse? I wrote a quick and dirty regex to remove whitespace from the .ui file, and all worked fine. But I wouldn't trust it with a real project, as it's likely to be a bit greedy in removing stuff :)

ERROR:pygubu.builderobject:Failed to set property 'selectmode'. TclError: bad selectmode "
extended
": must be none, browse, or extended

Menu Button

Hello! I am new to Pygubu, but already think it is amazing! So right now I am working on making a menu button. I would like to have the options be added in the python part to I can make it so it has all the user's usernames on it, Thanks for your help!

How to run pygubu application?

In the README.md file of this repository, there's no specification on how to run the pygubu application/GUI designer. There's just an example of an application created, I suppose, with pygubu, and I was able to run it.

On my mac OS X, I cannot simply type pygubu on the terminal and the GUI designer appears (like you did in the youtube video). I had to do a painful workaround.

If I install pygybu using pip3 with the following command:

pip3 install pygubu

In my Python folder site-packages, I have my pygubu folder (and I can therefore import pygubu from the IDLE), but that folder is simply this: https://github.com/alejandroautalan/pygubu/tree/master/pygubu
Which is actually a subfolder of this repository (and not all the repository).

I couldn't run the pygubu designer from that folder... there was not script to run it, or something similar.

I decided to clone this whole repository, and I finally discover that under /bin/ there's a script, which allows us to run pygubu.

This was very painful for me, and I hope you provide a complete guide on how to run the pygubu designer for various platforms, and not just for Ubuntu, where I suppose you can simply type magically pygubu from the terminal.


Edit:

I had noticed that I can now run pygubu from the terminal by simply typing pygubu-designer instead of simply pygubu...

Theme problems on Windows XP

For some reason, the 3 titlebar buttons (close, maximise, minimise), as well as the window border keep jumping back to Windows 2000 theme. Even stranger is when I preview the app in the designer, it generally uses the correct XP theme, but when I run the app standalone, it all goes very 1990s. The pygubu designer does this too, and I've tried all the ttk themes from the menu. That changes the controls' look, but not the window itself.

What's more odd is that when the window is first displayed, everything looks as it should (rounded XP titlebar buttons, red Close button), but as soon as I resize or move the app's window, those buttons are replaced with the old grey square ones from a previous version of windows - much like on the console window.

Any ideas? I realise this might be a tkinter problem rather than pygubu...

Thanks,

David.

py2exe problem

Hi,
i want to use your tool in combination with py2exe. However, when i try to compile your example button_cb.py py2exe says it could not find tkinter and ElementC14N modules.

It is possible to use py2exe with a normal tkinter or ttk application without any problem.

I think it might be some problem with python 2.7 and 3.x compatibility.

Steps to reproduce:

install py2exe (http://www.py2exe.org/)
write a setup.py file


import sys
from distutils.core import setup
import py2exe

sys.argv.append("py2exe")

setup(console=['button_cb.py'],
data_files=[("",
["button_cb.ui" # copy the ui file
])])


the output of the setup script results in the message:


The following modules appear to be missing
['ElementC14N', 'tkinter']


I am using windows 7 and my ptython version is 2.7.9

Please have a look at this issue and let me know if you need any additional information

Thanks Florian

Panedwindow inconsistent "grid row/column options"

zaazbb commented:

2-, when I first create ui, "Grid row/column options" in Panedwindow_1's Layout page have 3 line(2 rows and 1 column), as this:

-----Grid row/column options----------
| minisize pad weight |
| Row 0: 0 0 0 |
| Row 1: 0 0 0 |

| Column 0: 0 0 0 |

when I save ui file, and reopen it use menu "File-Open", the grid option change to 2 line(1 rows and 1 column), as below:

-----Grid row/column options----------
| minisize pad weight |
| Row 0: 0 0 0 |

| Column 0: 0 0 0 |

Created from comment: #2 (comment)

error: option --single-version-externally-managed not recognized

installing pygubu-0.9.4.1.tar.gz use pip, met a error. full message as below.

C:\Documents and Settings\jf>pip install pygubu
Downloading/unpacking pygubu
  Running setup.py (path:C:\DOCUME~1\jf\LOCALS~2\Temp\pip_build_jf\pygubu\setup.
py) egg_info for package pygubu

Installing collected packages: pygubu
  Running setup.py install for pygubu
    usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: -c --help [cmd1 cmd2 ...]
       or: -c --help-commands
       or: -c cmd --help

    error: option --single-version-externally-managed not recognized
    Complete output from command C:\Python34\python.exe -c "import setuptools, t
okenize;__file__='C:\\DOCUME~1\\jf\\LOCALS~2\\Temp\\pip_build_jf\\pygubu\\setup.
py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n'
, '\n'), __file__, 'exec'))" install --record C:\DOCUME~1\jf\LOCALS~2\Temp\pip-p
w6eud3k-record\install-record.txt --single-version-externally-managed --compile:

    usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]

   or: -c --help [cmd1 cmd2 ...]

   or: -c --help-commands

   or: -c cmd --help



error: option --single-version-externally-managed not recognized

menu.ui

0 False File 0 on_mfile_item_clicked True Open on_mfile_item_clicked True Quit False Help 0 on_about_clicked False About 200 200 0 True 0 nesw 20 Menu tips and tricks. 0 True 0

Cannot run pygubu-designer at OSX 10.9.2

Here it is - at first glance he cannot recognize UTF-8 locale. (Installed with pip on Python 2.7.5)

Running Python sys.version_info(major=2, minor=7, micro=5, releaselevel='final', serial=0) on 'darwin'
Pygubu: v. 0.9.7.6
Traceback (most recent call last):
File "/usr/local/bin/pygubu-designer", line 45, in
from pygubudesigner import main
File "/Library/Python/2.7/site-packages/pygubudesigner/main.py", line 44, in
from .uitreeeditor import WidgetsTreeEditor
File "/Library/Python/2.7/site-packages/pygubudesigner/uitreeeditor.py", line 31, in
from .widgeteditor import WidgetEditor
File "/Library/Python/2.7/site-packages/pygubudesigner/widgeteditor.py", line 28, in
from pygubudesigner.propertieseditor import PropertiesEditor
File "/Library/Python/2.7/site-packages/pygubudesigner/propertieseditor.py", line 31, in
from pygubudesigner.i18n import translator as _
File "/Library/Python/2.7/site-packages/pygubudesigner/i18n.py", line 32, in
lc, encoding = locale.getdefaultlocale()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 511, in getdefaultlocale
return _parse_localename(localename)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 443, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8

Please rename "Scripts/pygubu.py" to "Scripts/pygubu-script.py"

My problem: My application uses yourTkinter GUI framework GitHub "alejandroautalan/pygubu" and installs the application by distutils. If I call the application by commandline, there is the error message as “pygubu.py” is both the name of script in the folder “Scripts” ( which I don´t want to import, but which Python tries to import here ) and a name of a module of the application ( which I want to import here ).

The error message:

File "C:\Python27\lib\site-packages\codebreaker_package\pygubu_codebreaker.py", line 33, in <module>
    import pygubu
  File "C:\Python27\Scripts\pygubu.py", line 43, in <module>
    print("Pygubu: v. %s" % (pygubu.__version__,))
AttributeError: 'module' object has no attribute '__version__'

My solution: Rename “Scripts/pygubu.py” to “Scripts/pygubu-script.py” and add a batch file “pygubut.bat” and “pygubu.sh” respectively, which just call “python pygubu-script.py”.

Sincerely
Rolf

ValueError: unknown locale: UTF-8

When I first run pygubu I had a problem saying something like this:

ValueError: unknown locale: UTF-8

I solved it adding some lines to the ~/.bash_profile file:

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

Yes, I am on a Mac OS X Yosemite, and I suppose you did not have the problem running it from Linux.

some ideas for pygubu.

  1. Create callback function automatically for every button,named as on_buttonname_clicked(). If have a option on menu button, it's better.
  2. Import variables to App class by a helper method, so do not need call get_variable() lots times.
  3. Make a layout design by Dragging widget on review panel directly. Maybe can use DndHandler class in dnd.py.
  4. Add align tool button or menu button.Add layout widget(eg:frame, grid) automatically, when a align button clicked. A better reference is QT gui designer.
  5. pygubu not just create ui file, also create App file. (Open source editer window and)Jump to the callback function directly when a button clicked on review panel.

Preview and actual effect is not consistent

I want widgets auto expand to max size when main window resizing. in the preview window, it can autoresize, but actual effect it can't.

here is the ui file as below and python main script:

<?xml version="1.0" ?>
<interface>
  <object class="ttk.Panedwindow" id="Panedwindow_1">
    <property name="height">200</property>
    <property name="orient">vertical</property>
    <property name="width">200</property>
    <layout>
      <property name="column">0</property>
      <property name="propagate">True</property>
      <property name="row">0</property>
      <property name="sticky">nesw</property>
      <columns>
        <column id="0">
          <property name="weight">0</property>
        </column>
      </columns>
      <rows>
        <row id="0">
          <property name="weight">0</property>
        </row>
        <row id="1">
          <property name="weight">0</property>
        </row>
      </rows>
    </layout>
    <child>
      <object class="ttk.Panedwindow.Pane" id="Pane_1">
        <property name="weight">1</property>
        <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>
            </layout>
            <child>
              <object class="tk.Text" id="Text_1">
                <property name="height">10</property>
                <property name="text" translatable="yes">Text_1</property>
                <property name="width">50</property>
                <property name="wrap">char</property>
                <layout>
                  <property name="column">0</property>
                  <property name="propagate">True</property>
                  <property name="row">0</property>
                </layout>
              </object>
            </child>
          </object>
        </child>
      </object>
    </child>
    <child>
      <object class="ttk.Panedwindow.Pane" id="Pane_2">
        <property name="weight">1</property>
        <child>
          <object class="pygubu.builder.widgets.scrollbarhelper" id="scrollbarhelper_2">
            <property name="scrolltype">both</property>
            <layout>
              <property name="column">0</property>
              <property name="propagate">True</property>
              <property name="row">0</property>
            </layout>
            <child>
              <object class="tk.Text" id="Text_2">
                <property name="height">10</property>
                <property name="text" translatable="yes">Text_2</property>
                <property name="width">50</property>
                <property name="wrap">char</property>
                <layout>
                  <property name="column">0</property>
                  <property name="propagate">True</property>
                  <property name="row">0</property>
                </layout>
              </object>
            </child>
          </object>
        </child>
      </object>
    </child>
  </object>
</interface>
#test.py
import tkinter as tk
import pygubu

class Application:
    def __init__(self, master):

        #1: Create a builder
        self.builder = builder = pygubu.Builder()

        #2: Load an ui file
        builder.add_from_file('111.ui')

        #3: Create the widget using a master as parent
        self.mainwindow = builder.get_object('Panedwindow_1', master)

if __name__ == '__main__':
    root = tk.Tk()
    app = Application(root)
    root.mainloop()

Add .png format to pygubu StockImage

By changing line 45 of stockimage.py to
_formats = ('.gif','.png',)

stock images normally used for kde buttons can really be used (not just .gif)

Thanks.

Wrong textvariable format when create ui file.

under pygubu v0.9.6.3, make a wrong textvariable format when create ui file. wrong format as below:

 <property name="textvariable">string:svPktDat</property>

the right variable format should be "svPktDat:string". right format as below:

<property name="textvariable">svPktDat:string</property>

now, under pygubu v0.9.6.3, met a KeyError, when running builder.get_variable().

tk.message textvariable

Dumb question (maybe just a beginner question). I have set up a gui using pygubu and want to use a tk.message display. I have set up a string textvariable which I'm assuming I can set in the python script. I just can't work out how to set the variable. Please could you give an example?

(pygubu seems a great way of creating a gui by the way!)

Dave

pygubu

I installed pygubu from source tarball. Tried to run, got following error:

Running Python sys.version_info(major=3, minor=4, micro=2, releaselevel='final', serial=0) on 'linux'
Pygubu: v. 0.9.4.5
Traceback (most recent call last):
File "/usr/local/bin/pygubu", line 47, in
main.start_pygubu()
File "/usr/local/lib/python3.4/dist-packages/pygubudesigner/main.py", line 511, in start_pygubu
app = PygubuUI(root)
File "/usr/local/lib/python3.4/dist-packages/pygubu/init.py", line 17, in init
self._create_ui()
File "/usr/local/lib/python3.4/dist-packages/pygubudesigner/main.py", line 165, in _create_ui
self.properties_editor = WidgetPropertiesEditor(self)
File "/usr/local/lib/python3.4/dist-packages/pygubudesigner/propertieseditor.py", line 69, in init
self.arrayvar = PropertiesArray()
File "/usr/lib/python3.4/tkinter/init.py", line 249, in init
self.initialize(self._default)
File "/usr/local/lib/python3.4/dist-packages/pygubudesigner/util/init.py", line 87, in set
self._master.eval("array set {%s} {}" % self._name)
AttributeError: 'PropertiesArray' object has no attribute '_master'
Exception ignored in: <bound method PropertiesArray.del of <pygubudesigner.propertieseditor.PropertiesArray object at 0xb5ecab2c>>
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/pygubudesigner/util/init.py", line 56, in del
self._tk.globalunsetvar(self._name)
_tkinter.TclError: can't unset "PY_VAR1": no such variable

This happens in a virtualenv environment and when running directly from command line.

Sorry for posting this here, I couldn't find anywhere else to get help with pygubu.

Invalid layout grid columns/rows saved in xml file.

  1. Create a frame with two grid columns (label + entry).
  2. Configure frame colums to be resizable (weight = 1)
  3. Delete second column (entry)
  4. Save file.

The generated file contains the description of the deleted column. It should not.

insert value on TreeView Column

Hi Alejandro!
I need your help!
Do you explain to me what I need to insert value on TreeView Column ?
Thank You!
Regards.
Husni Ali Husni

Install issues with latest version on Win32

Hi, Following the other thread (thanks v much for the advice, really looking forward to trying it out!), I downloaded the latest version. There are 2 problems I think on Win32:

  1. The tar file contains some files which have duplicate names except for the case of the characters - this isn't possible on Win32, and so the extraction overwrites some files as it's going and complains. This doesn't seem to caused problems yet - it's in one of the 16x16 folders (for icon images I guess).
  2. Perhaps there's an upgrade process I should have followed which caused this, but when I try and run the designer now, I get this error:

Running Python sys.version_info(major=2, minor=7, micro=1, releaselevel='final', serial=0) on 'win32'
Pygubu: v. 0.9.4
Traceback (most recent call last):
File "pygubu", line 45, in
from pygubudesigner import main
File "C:\Python27\pygubu-master\pygubudesigner\main.py", line 49, in
from .propertieseditor import WidgetPropertiesEditor
File "C:\Python27\pygubu-master\pygubudesigner\propertieseditor.py", line 31, in
from .widgets import ColorEntry, Textentry, TkVarEntry, ImageEntry
File "C:\Python27\pygubu-master\pygubudesigner\widgets__init__.py", line 5, in
from .sizeentry import SizeEntry
File "C:\Python27\pygubu-master\pygubudesigner\widgets\sizeentry.py", line 1
SyntaxError: Non-ASCII character '\xc3' in file C:\Python27\pygubu-master\pygubudesigner\widgets\sizeentry.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

I used the exact same download / unzip process as last time, but obviously something's upset it. I actually just deleted line 1 from the offending file, and all seems OK now. Is it a (C) symbol perhaps? I didn't see anything in my text editor (Sublime Text)...

No able to receive window close button event

For Example :

def on_close():
print ("Closed application")

root = tkinter.Tk()
root.protocol("WM_DELETE_WINDOW", on_close)
app = Application(root)
app.run()

Not sure how to catch window close event.
It will be helpful if anyone can suggest me on this.

(Big thanks for pygubu ☺️ )

Infinite loop when resizing window with Text inside ScrolledFrame

Infinite loop when resizing window.

Scenary:

  • Having a ScrolledFrame > ScrollbarHelper > Text
  • All the widgets are set to resize.
  • Scrolltype is set to both
  • Text wrap is set to none

Tip: Does not happen if Text wrap is set to "char" or "word"

Example:

<?xml version='1.0' encoding='utf-8'?>
<interface>
  <object class="tk.Toplevel" id="Toplevel_1">
    <property name="height">200</property>
    <property name="resizable">both</property>
    <property name="width">200</property>
    <child>
      <object class="ttk.Labelframe" id="Labelframe_3">
        <property name="height">200</property>
        <property name="text" translatable="yes">Labelframe_3</property>
        <property name="width">200</property>
        <layout>
          <property name="column">0</property>
          <property name="propagate">True</property>
          <property name="row">0</property>
          <property name="sticky">nsew</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.scrolledframe" id="scrolledframe_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">nsew</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="ttk.Frame" id="Frame_1">
                <property name="height">200</property>
                <property name="width">200</property>
                <layout>
                  <property name="column">0</property>
                  <property name="propagate">True</property>
                  <property name="row">0</property>
                </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">nsew</property>
                    </layout>
                    <child>
                      <object class="tk.Text" id="Text_1">
                        <property name="height">10</property>
                        <property name="text" translatable="yes">WARNING:pygubu.designer:No selecciono item.
alejandro@sentey:~/tmp/pygubuimages$ 
alejandro@sentey:~/tmp/pygubuimages$ 
alejandro@sentey:~/tmp/pygubuimages$ 
alejandro@sentey:~/tmp/pygubuimages$ 
alejandro@sentey:~/tmp/pygubuimages$ 
alejandro@sentey:~/tmp/pygubuimages$ 
alejandro@sentey:~/tmp/pygubuimages$ 
alejandro@sentey:~/tmp/pygubuimages$ 
alejandro@sentey:~/tmp/pygubuimages$ 
alejandro@sentey:~/tmp/pygubuimages$ 
alejandro@sentey:~/tmp/pygubuimages$ 
alejandro@sentey:~/tmp/pygubuimages$ 
alejandro@sentey:~/tmp/pygubuimages$ 
alejandro@sentey:~/tmp/pygubuimages$ 
alejandro@sentey:~/tmp/pygubuimages$ 
alejandro@sentey:~/tmp/pygubuimages$ /home/alejandro/codigofuente/python/pygubu/bin/pygubu-designer
Running Python sys.version_info(major=3, minor=4, micro=2, releaselevel='final', serial=0) on 'linux'
Pygubu: v. 0.9.7.4</property>
                        <property name="width">50</property>
                        <property name="wrap">none</property>
                        <layout>
                          <property name="column">0</property>
                          <property name="propagate">True</property>
                          <property name="row">0</property>
                          <property name="sticky">nsew</property>
                        </layout>
                      </object>
                    </child>
                  </object>
                </child>
              </object>
            </child>
          </object>
        </child>
      </object>
    </child>
  </object>
</interface>

Issue with scrolling bar in Widget Properties Editor

( Really useful GUI builder for fast prototyping. Thanks ! )

System:
Macbook pro with Mavericks

Issue:
Scrolling bar freeze ( only seen in the "General" tab of the widget properties editor, although that might also happen with the "Layout" tab in a small application window configuration )

Initial Condition:
In the middle of configuring widget properties. somewhat hard to reproduce.

Other:
Sometimes, would recover on its own; sometimes wouldn't.

How to access ( deselect, add, scroll, mark ) a Listbox respectively its contents ?

How to access ( deselect, add, scroll, mark ) a Listbox respectively its contents ?

Tipp:
I found out how to get data from input field

_entry_1 = self.builder.get_object('Entry_1')
result = _entry_1.get()

while "Entry_1" is entered in pygubu for the "Entry" element as textvariable of type string.

So with the competitive Tkinter GUI editor "SpecTCL", I wrote
# Deselect the old last entry
self._listbox_1.select_clear(END)
# Add an entry
self._listbox_1.insert(END, text)
# Scroll at the end of the list
self._listbox_1.see(END)
# mark last item
self._listbox_1.selection_set(END)
So how to do that with pygubu?

Though I know other Tkinter GUI editors, and Tkinter, I can´t get the clue.

In general, the examples currently shipped with pygubu miss such basic cases.. in many cases. E.g. my example here of the use of a ttk_entry / tk_entry field is not yet documented in examples... nor that for a listbox.

Sincerely
Rolf

With Pygubu 0,95, "pygubu" is no valid command on commandline on Windows 8.1

Expected behaviour, as shown by pygubu 0.94.1:
On Windows 8.1 with Python(x,y), the gui builder may be called by pygubu from command line shell, after installation with "python setup.py install" from the installation directory.

Bug #1 for pygubu 0.94.1:
Indeed on my system, in opposite to other python applications like "behave", which just execute as expected, here
the Pyscripter editor is called, loading the pygubu application.
So that I may call it.

Bug #2 for pygubu 0.95:
Watched behaviour, with pygubu 0.95:
this is not true anymore.
Pygubu is no valid command on commandline.
I don´t know how to call it, at all :-(

So I reinstalled 0.94.1 again...

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.