1 | # n4dGtkLogincomponent |
---|
2 | This is a Lliurex specific login component for Gtk apps. |
---|
3 | ### API |
---|
4 | ###### set_mw_proportion_ratio(columns_left,columns_right) |
---|
5 | Sets the portion of screen reserved to each component (info and login form). It works splitting the main window in (columns_left+columns_right) columns and asigning to each part the desired number of columns. By default the proportion is set to 2:1 |
---|
6 | ###### set_mw_background(image=None,cover=False,from_color=None,to_color=None,gradient='linear') |
---|
7 | Sets the background for the login box. It can be a system's image or gradient going "from_color" to "to_color". By default all fields are "None" and only radial and linear gradients are supported. If we set a background image and set cover=True then the image will cover all the box area. |
---|
8 | ###### set_login_background(image=None,cover=False,from_color=None,to_color=None,gradient='linear') |
---|
9 | Sets the background for the login box. It can be a system's image or gradient going "from_color" to "to_color". By default all fields are "None" and only radial and linear gradients are supported. If we set a background image and set cover=True then the image will cover all the box area. |
---|
10 | ###### set_default_username(default_username) |
---|
11 | Sets the placeholder of the "username" entry to "default_username" |
---|
12 | ###### set_default_server(default_server) |
---|
13 | Sets the placeholder of the "server" entry to "default_server" |
---|
14 | ###### set_login_banner(image) |
---|
15 | Sets the user's image for the login form, by default is "llx-avatar" |
---|
16 | If the image isn't a full path then is searched in the default theme. |
---|
17 | ###### set_info_banner(image,resx=72,resy=72) |
---|
18 | Sets the info box banner, by default is "None". The resolution is set to 72X72 by default. |
---|
19 | ###### set_info_background(image=None,cover=False,from_color=None,to_color=None,gradient='linear') |
---|
20 | Sets the background for the info box. It can be a system's image or gradient going "from_color" to "to_color". By default all fields are "None" and only radial and linear gradients are supported. If we set a background image and set cover=True then the image will cover all the box area. |
---|
21 | ###### set_info_text(title,subtitle,text) |
---|
22 | Sets the information to show in the info box. |
---|
23 | It must have a title, a subtitle and a text as arguments and supports markup language. |
---|
24 | ###### get_action_area() |
---|
25 | Returns the info box so we can add any widget to it. |
---|
26 | ###### render_screen() |
---|
27 | Returns the rendered main box. |
---|
28 | ###### after_validation_goto() |
---|
29 | Sets the function that the loginComponent will launch after a correct user's validation |
---|
30 | |
---|
31 | ### Examples |
---|
32 | ```python |
---|
33 | #!/usr/bin/env python3 |
---|
34 | import gi |
---|
35 | gi.require_version('Gtk', '3.0') |
---|
36 | from gi.repository import Gtk |
---|
37 | from edupals.ui.n4dgtklogin import * |
---|
38 | |
---|
39 | def _signin(): |
---|
40 | print("OK") |
---|
41 | print("Now hide the login component and make things") |
---|
42 | |
---|
43 | def start_gui(): |
---|
44 | mw=Gtk.Window() |
---|
45 | box=Gtk.Box() |
---|
46 | loginComponent=N4dGtkLogin() #Init the login component |
---|
47 | loginComponent.set_info_text("<span foreground='black'>Title</span>","Subtitle","Text text text.\nText text text:\n<sub>* text with sub tag</sub>") |
---|
48 | #Uncomment and comment... |
---|
49 | ##Change the proportion ratio |
---|
50 | #loginComponent.set_mw_proportion_ratio(2,1) |
---|
51 | #loginComponent.set_mw_proportion_ratio(1,2) |
---|
52 | #loginComponent.set_mw_proportion_ratio(3,9) |
---|
53 | #loginComponent.set_mw_proportion_ratio(8,5) |
---|
54 | ##- Setting a background for the component |
---|
55 | #loginComponent.set_mw_background(image='/usr/share/backgrounds/ubuntu-mate-xenial/The_MATErix.png') |
---|
56 | ##- Setting a background for the form |
---|
57 | #loginComponent.set_form_background(from_color='grey',to_color='white',gradient='radial') |
---|
58 | ##- Adding a widget to the info box |
---|
59 | #infobox=loginComponent.get_action_area() |
---|
60 | #infobox.add(Gtk.Label("Add widget")) |
---|
61 | ##- Changing the background for the info box |
---|
62 | #loginComponent.set_info_background(from_color='#000000',to_color='white',gradient='linear') |
---|
63 | #loginComponent.set_info_background(image='/usr/share/backgrounds/ubuntu-mate-xenial/The_MATErix.png') |
---|
64 | ##- Changing default values for entries |
---|
65 | #loginComponent.set_default_username("Put your name") |
---|
66 | #loginComponent.set_default_server("Put your server") |
---|
67 | ##- Changing banners |
---|
68 | #loginComponent.set_login_banner('/usr/share/filezilla/resources/flatzilla/48x48/uploadadd.png') |
---|
69 | #loginComponent.set_info_banner('/usr/share/filezilla/resources/flatzilla/24x24/folder.png') |
---|
70 | ##- Function that will be launched after a succesfull validation |
---|
71 | loginComponent.after_validation_goto(_signin) |
---|
72 | ##- Render the form |
---|
73 | loginBox=loginComponent.render_form() |
---|
74 | ## |
---|
75 | box.add(loginBox) |
---|
76 | mw.add(box) |
---|
77 | mw.connect("delete-event",Gtk.main_quit) |
---|
78 | mw.show_all() |
---|
79 | |
---|
80 | start_gui() |
---|
81 | Gtk.main() |
---|
82 | ``` |
---|