New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Center and stretch Message to the border of the window #435

Closed
stephanepiriou opened this Issue Apr 12, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@stephanepiriou

stephanepiriou commented Apr 12, 2018

I can't figure out how to stretch the message widget on the whole width of the window

app = gui("Login Form")

app.addMessage("Message","Veuillez entrer les parametres de votre système d\'équation.", 0, 0, colspan=2)

app.addLabel("nbrEquations", "Nombre d'équations:", 1, 0)
app.addNumericEntry("userEnt", 1, 1)

app.addLabel("nbrUnknowns", "Nombre d\'inconnues:", 2, 0)
app.addNumericEntry("passEnt", 2, 1)

app.addButtons(["Create", "Cancel"], None, colspan=3)

selection screen shot53

@mpmc

This comment has been minimized.

Contributor

mpmc commented Apr 12, 2018

Use a label instead :)

from appJar import *

app = gui("Login Form")

app.addLabel("Message","Veuillez entrer les parametres de votre système d\'équation.", 0, 0, colspan=2)

app.addLabel("nbrEquations", "Nombre d'équations:", 1, 0)
app.addNumericEntry("userEnt", 1, 1)

app.addLabel("nbrUnknowns", "Nombre d\'inconnues:", 2, 0)
app.addNumericEntry("passEnt", 2, 1)

app.addButtons(["Create", "Cancel"], None, colspan=3)

app.go()
@jarvisteach

This comment has been minimized.

Owner

jarvisteach commented Apr 12, 2018

Actually, quite an interesting one...

Long answer short, as @mpmc says, just use a label!

But, after a bit more research - the message has been stretched, add this line to check:
app.setMessageBg("Message", "blue")

According to this, message widgets are just labels with one extra feature, they split the text over multiple lines.

If you want to control how the text is split, you can either give it a new width value: app.setMessageWidth("Message", 200)

Or you can change its aspect ratio:

mess = app.addMessage("Message","Veuillez entrer les parametres de votre système d\'équation.", 0, 0, colspan=2)
mess.config(aspect=500)

I will add a new function for setting the aspect on messages, and update the documentation to better explain it.

@jarvisteach jarvisteach added this to the 1.0 milestone Apr 12, 2018

jarvisteach added a commit that referenced this issue Apr 12, 2018

Investigating #435
New `aspect` function and updated docs
@stephanepiriou

This comment has been minimized.

stephanepiriou commented Apr 13, 2018

Great. It works :

app.setMessageWidth("Message", 200)

Thank you.

Just to make it clear, the AppJar is a wrapper for Tk ?

If it's the case, it seems all function are not implemented, at least if I understand well the logic. There should have a setMessageJustify() method, as with setMessageAnchor() which is recognized, but the console tell me it doesn't exist.

Plus, Pycharm doesn't seems to predict methods other than setMessage()...

I suppose I missing something...

Is there an api documentation for AppJar other than the tutorial ?

@jarvisteach

This comment has been minimized.

Owner

jarvisteach commented Apr 13, 2018

Yes, appJar is just a wrapper around tkinter, grouping together multiple calls, to try to make life a bit easier. A lot of tkinter hasn't been implemented, and probably never will. You can always get at the tkinter widgets and work with them directly...

Have a look here if you need more information: http://appJar.info

For your question about anchor/justify/align, have a look here: http://appjar.info/pythonWidgetOptions/#advanced-looks

The command you need is: app.setMessageAlign("Message", "right")

eg.

def align(btn): app.setMessageAlign("Message", btn.lower())
app.addButtons(["Left", "Right", "Center"], align, colspan=3)

@jarvisteach jarvisteach closed this May 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment