-
Notifications
You must be signed in to change notification settings - Fork 68
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
Style classes like CSS? Have to set font each widget. #481
Comments
Hi @Whearly - glad you're enjoying using appJar. There is an example of how to set the font on the page you mention: http://appjar.info/pythonGuiOptions/#font app.setFont(size=16, family="Times", underline=True, slant="italic")
app.setButtonFont(size=14, family="Verdana", underline=False, slant="roman") And it seems to work fine on my platform. |
@Whearly - I've been thinking about this a bit more and have come up with the following... First create your stylesheet, called body = {
'geom':'400x400',
'font':{'size':33, 'family':"helvetica", 'weight':'normal', 'underline':False, 'slant':"roman", 'overstrike':False},
'bg':'yellow',
'fg':'red'
}
t1 = {
'font':{'size':16, 'family':"times", 'weight':'normal', 'underline':False, 'slant':"italic", 'overstrike':True},
'bg':'red',
'fg':'pink'
}
t2 = {
'font':{'size':20, 'family':"times", 'weight':'normal', 'underline':False, 'slant':"italic", 'overstrike':True},
'bg':'green',
'fg':'orange'
}
t3 = {
'font':{'size':24, 'family':"times", 'weight':'bold', 'underline':True, 'slant':"roman", 'overstrike':False},
'bg':'blue',
'fg':'green'
}
t4 = {
'font':{'size':28, 'family':"times", 'weight':'bold', 'underline':True, 'slant':"roman", 'overstrike':False},
'bg':'yellow',
'fg':'blue'
} Then, use it in your code: from appJar import gui
import myStyle as style
with gui("appjar font problem", **style.body) as app:
app.label("l1", "Label 1")
app.label("l2", "Label 2")
app.label("l3", "Label 3", **style.t1)
app.label("l4", "Label 4", **style.t2)
app.label("l5", "Label 5", **style.t3)
app.label("l6", "Label 6", **style.t4)
app.label("l7", "Label 7") |
The We then just unpack the style in the call to add labels. |
I might look into making this a feature of a future release - appJar can auto look for a style file, and then have a specific parameter for style ids... |
Closing this, as happy with the current implementation. |
Is there a way to set font family and other stylings by class (as in CSS class) to avoid repetitious coding on each widget? As far as I can tell, I will have to set font family on each widget separately to avoid error messages and have already set all the other styles separately. It would be great if I could assign a class to a widget and then define the class once like in CSS. Thanks for the awesome GUI maker, I am in 7th heaven using appJar, finally able to make a front end for a sqlite db (I hope) without going to coder school for years. The reason I'm not able to set font globally (without error messages) is demonstrated below.
Setting font family works but this error appears in the console every time I run a program in which I've set font family.
The text was updated successfully, but these errors were encountered: