Package: gaspium
GaspiumFramework to build Python apps with the GASP metaphorThis project is part of thePyrustic Open Ecosystem.Installation.Demo.Latest.DocumentationTable of contentsOverviewAppPageCommand line awareBatteries includedInstallationDemoOverviewGaspiumis a framework that allows you to create applications with theGASP(GUIAsStapledPages) metaphor.In short, we definepagesto which we add graphicalcomponents. Then we add thesepagesto an instance of theAppclass. The firstpageadded is de facto thehome pageand it will be open when the application is started. Adding apagemakes it automatically referenced in the application'snavigation bar. You can open an arbitrarypageof your application directly from thecommand line.Gaspiumserves as the reference implementation of theGASP concept.Discover theGASP concept!AppIt is the main class of the Framework. An instance of the App class represents the running application. It is to this instance that the developer adds Pages.fromgaspiumimportAppapp=App()# ...# Here you add pages to the app# The first page is considered the home page# ...# The last line starts the app (mainloop)# The home page will open automaticallyapp.start()TheAppclass accepts arguments like the theme to use, the geometry of the window, whether the caching should be enabled or not, et cetera. TheAppclass also has theaddmethod to add a page to the application,openmethod to open a page,startmethod to start the application,exitmethod to exit the application, et cetera.Read the Appdocumentation.PageAPageis either a function or aViewablesubclass. Each Page added to the App instance is either manually or automatically assigned a unique page identifier, the PID, and automatically referenced in the navigation bar. A page is rebuilt or not at each opening depending on whether thecachingfeature has been activated or not.importtkinterastkfromviewableimportViewablefromgaspiumimportAppdefhome_page(context):"""Home Page. Must accept the dto argument"""# the dto contains some useful objectsapp=context.apppid=context.piddata=context.dataroot=context.root# the page function must returns the body# i.e. the graphical container of the pagebody=tk.Frame(root)label=tk.Label(body,text="Home")label.pack()returnbodyclassLoginPage(Viewable):"""Login Page"""def__init__(self,context):"""The constructor must accept the dto argument"""super().__init__()# the dto contains some useful objectsself._app=context.appself._pid=context.pidself._data=context.dataself._root=context.root# the body of the pageself._body=Nonedef_build(self):self._body=tk.Frame(self._root)label=tk.Label(self._body,text="Login")label.pack()defon_open_home(context):"""This on_open callback must accept a dto object"""# redirect to login_page# instead of letting the home_page openapp=context.appapp.open("login")app=App(caching=False)# Add home_page and bind the 'on_open_home' callback# to perform a custom redirection to login_pageapp.add(home_page,title="Home",on_open=on_open_home)# Add login_page (it won't be referenced in the navigation bar)app.add(LoginPage,pid="login",title="Login",indexable=False)# The home page will open automaticallyapp.start()Play with theDemo.Command line awareBy default, when you run a GASP application, the first page added to the App instance opens as the home page. It is possible to open an arbitrary page of the application from the command line. To do this, just put its PID (Page ID) as an argument on the command line. The strings entered after the identifier are considered as data to be sent to the page when it is opened.$my-applogin"Alex Rustic"# the login page will openBatteries includedGaspiumcomes with a handful of useful lightweight packages.NameDescriptionBackstageExtensible command line tool for managing software projectsCyberpunk-ThemeA moderndark themefor Python appsSharedData exchange and persistenceSubrunIntuitive API to safely start and communicate with processes in PythonTkStyleLibrary to create styles and themes for Python appsMegawidgetCollection of megawidgets to build graphical user interfaces for Python appsViewablePython library to implement a GUI view with lifecycleThreadomTkinter-compatible multithreadingSuggestionDemocratizing auto-complete(suggest) for Python desktop applicationsKurlKonnection URL: HTTP requests in Python with an implementation of conditional request and a responses caching systemInstallationGaspiumiscross platformand versions under1.0.0will be consideredBetaat best. It is built onUbuntuwithPython 3.8and should work onPython 3.5ornewer.For the first time$pipinstallgaspiumUpgrade$pipinstallgaspium--upgrade--upgrade-strategyeagerDemoA demo is available to play with as aGithub Gist. Feel free to give a feedback in the comments section.Play with theDemo.Back to top