omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Using abstract classes with ui.View

    Pythonista
    1
    1
    799
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Phuket2
      Phuket2 last edited by

      I am just doing some testing with Abstract classes. I would like to start using them to help with the design of my classes and also help with a consistent approach. From what I read the code below should not work, it should fail as an abstract method in the child class is not defined. But, I think I am having problems because I am inheriting from ui.View. Is there something special about ui.View that does not allow combining it with abstract classes?
      Any help appreciated.

      
      import ui
      from abc import ABCMeta, abstractmethod
      
      #template custom class
      class base_std(ui.View):
      	__metaclass__ = ABCMeta
      	def __init__(self):
      		pass
      		
      	def ui_elements_create():
      		pass
      	
      	@abstractmethod
      	def style(self):
      		pass
      	
      	def layout(self):
      		pass
      		
      class my_class(base_std):
      	def __init__(self):
      		pass
      		
      	#def style(self):
      		#pass
      
      if __name__ == '__main__':
      	cls= my_class()
      	cls.present('sheet')
      
      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Powered by NodeBB Forums | Contributors