Package: pynamicui
PynamicUIPynamicUI is a lightweight Python library that provides a dynamic user interface (UI) framework for creating interactive and responsive applications. It simplifies the process of building user interfaces by abstracting away the complexities of working directly with a UI toolkit like Tkinter. With PynamicUI, you can create dynamic web-like UIs using a declarative syntax, making it easy to define and manage the UI components and their interactions.FeaturesDeclarative Syntax:Define UI components using a declarative syntax similar to HTML, making it intuitive and easy to manage.Dynamic Rendering:Efficiently render virtual elements as tkinter widgets, ensuring responsiveness and interactivity.State Management:Manage the state of your application and automatically update the UI when state changes occur.Hooks and Effects:Utilize hooks and effects to add custom logic and side effects to elements, enhancing interactivity.Styling Capabilities:Apply styles to UI elements with ease, allowing for seamless customization of appearance.Responsive and Interactive UIs:Build dynamic and responsive user interfaces with web-like interactions.InstallationPynamicUI requires theCustomTkinterlibrary. To install PynamicUI and its dependencies, you can usepip:pipinstallpynamicuiDocumentationFor detailed documentation and usage examples, please refer to thePynamicUI Wiki.ExamplesCheck out theexamplesfolder for practical examples building an application with PynamicUI.Example Calculator AppExplore a step-by-step tutorial on how to build a simple calculator app using PynamicUI.Example Counter AppSee a practical example of creating a counter app to learn more about PynamicUI's state management and hooks.Example Dynamic ListDiscover how to create a dynamic list using PynamicUI's powerfulplacemethod for flexible and responsive UI elements.Example NavBar AppExplore a tutorial on building a navigation bar with buttons to switch between different pages in your application.An abstraction of CustomTkinterPynamicUI supports nearly all the same elements asCustomTkinter.Getting StartedUsing PynamicUI in a New ProjectTo start using PynamicUI in a new project, follow these steps:Import the required classes and functions from PynamicUI:frompynamicuiimportcreateStylesheet,createDom,createElement,setAppearanceModeimportcustomtkinterastkDefine your UI components using thecreateElementclass:classCounterApp:def__init__(self,dom):self.dom=dom# Create the counter state using dom.useStateself.dom.useState("counter",0,self.update_counter_label)# Create a label to display the counter valueself.counter_label=createElement(self.dom,"Label",props={"text":"Counter: 0"},place={"relwidth":1,"relheight":0.5})# Create a button to increment the counterself.increment_button=createElement(self.dom,"Button",style="PrimaryButton",props={"text":"Increment","command":self.increment_counter},place={"relwidth":1,"relheight":0.5,"rely":0.5})defincrement_counter(self):# Get the current counter valuecounter=self.dom.getState("counter")# Increment the counter valuecounter+=1# Update the counter stateself.dom.setState("counter",counter)defupdate_counter_label(self,prop,element,value):# Update the counter label text prop with the new counter valueself.counter_label.setProp("text",f"Counter:{value}")Add styles using thecreateStylesheetclass:styles=createStylesheet()styles.addStyle("PrimaryButton",{"font":("Arial",14,"normal"),"fg_color":"grey","bg_color":"blue"})styles.addStyle("SecondaryButton",{"font":("Arial",14,"normal"),"fg_color":"black","bg_color":"green"})Render the virtual DOM and launch your application:if__name__=="__main__":dom=createDom()dom.setStylesheet(styles)CounterApp(dom)dom.render()Integrating PynamicUI in an Existing ProjectTo integrate PynamicUI into an existing project, follow these steps:Install PynamicUI and its dependencies as described in theInstallationsection.Import the required classes and functions from PynamicUI:frompynamicuiimportcreateStylesheet,createDom,createElement,setAppearanceModeimportcustomtkinterastkIdentify the parts of your application where you want to use PynamicUI and create virtual elements accordingly.Add styles using thecreateStylesheetclass to customize the appearance of the UI elements.Implement state management and hooks to add interactivity and custom logic to your application.Render the virtual DOM and launch your application:if__name__=="__main__":dom=createDom(root=existingCustomTkinterRoot)ContributionsContributions to PynamicUI are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request onGitHub.Issue TrackingThis wiki page explains the proper procedures for submitting an issue related to PynamicUIIssue Tracking with PynamicUILicensePynamicUI is licensed under theApache License. Feel free to use, modify, and distribute this library as permitted by the license.AcknowledgmentsPynamicUI is built upon the foundation ofCustomTkinterby Tom Schimansky. Special thanks to the developers of CustomTkinter for their valuable contributions.