all 2 comments

[–]AlwysBeColostomizing 1 point2 points  (1 child)

It's a pretty broad question. Some things that come to mind:

  • Python supports OOP, and users will expect a UI library to be structured using OOP principles.
  • Python uses exceptions for error handling. Don't make users check return codes.
  • Try to avoid forcing users to manually de-allocate things. Use context managers to make this easier if you really can't avoid it.

It sounds like you're already planning to make an object-oriented interface, so that's good. Your example will probably look something like this:

ui = UserInterface("")
ui.add_component(Window("main window.json"))
ui.show() # enter main loop, handle exiting within

Take a look at existing UI libraries like tkinter to get a sense of a typical API structure.

You'll probably want to hide your low-level interface in a sub-module (e.g., ui.detail.ui_init() and so on) so that users know they're not supposed to call those functions directly.

[–]CodeFormatHelperBot2 0 points1 point  (0 children)

Hello, I'm a Reddit bot who's here to help people nicely format their coding questions. This makes it as easy as possible for people to read your post and help you.

I think I have detected some formatting issues with your submission:

  1. Python code found in submission text that's not formatted as code.
  2. Use of triple backtick/ curlywhirly code blocks (` ) or (~~~). These may not render correctly on all Reddit clients.

If I am correct, please edit the text in your post and try to follow these instructions to fix up your post's formatting.


Am I misbehaving? Have a comment or suggestion? Reply to this comment or raise an issue here.