screen update in screen manager












0















i'm using kivy for building an app screen with 3 screens.
my main screen ( class Base) is showing data from a SQL request.
i would like the user to be able to update these data using a button.
first this class Base is called in the screen manager which is itself called in my root class.
So my question is , how do i clear the data in my class Base and update it with the new data?



i tried to clear the data in my class screen manager.
the refresh function is called from the root class.
i have the below error:
'ScreenManager uses remove_widget only for removing Screens'



from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
from sql import runsql2
from kivy.core.window import Window

class Manager(ScreenManager):
def __init__(self):
super(Manager, self).__init__()

for i in range(2):
txt = 'Screen {}'.format(i)
lbl = Label(text=txt)
screen = Screen(name=txt)
screen.add_widget(lbl)
self.add_widget(screen)

base=Base('main')
self.add_widget(base)

def refresh(self):
self.clear_widgets(screens='main')
base=Base('main')
self.add_widget(base)


class Nav(GridLayout):

def __init__(self,sm=None):
super(Nav, self).__init__()

self.sm = sm
self.cols =3
self.size_hint = (1,0.1)
self.add_widget(Button(text="Clearing Screen", on_release=self.change))
self.add_widget(Button(text="Go screen 2", on_release=self.goscreen))
self.add_widget(Button(text="Quit", on_release=self.quit))

def change(self, btn):
#self.sm.current = btn.text
self.sm.current='main'

def quit(self,ins):
exit()

def goscreen(self,ins):
self.sm.current='Screen 1'

class Base(Screen):
def __init__(self,name):
super(Base, self).__init__()
self.lay=GridLayout()
self.name=name
self.bout=['[color=33ff99]Refresh[/color]','',"","","","","","","","",""]
self.data=runsql2()
self.lay.cols = 11
self.titre=['[color=ff9900]Market[/color]', '[color=ff9900]B/S[/color]', '[color=ff9900]Volume[/color]', '[color=ff9900]Contract[/color]',
'[color=ff9900]C/P[/color]', '[color=ff9900]Expiry[/color]', '[color=ff9900]Strike[/color]', '[color=ff9900]Price[/color]',
'[color=ff9900]Account[/color]', '[color=ff9900]Give up Member[/color]', '[color=ff9900]Allocation Account[/color]']

#self.lay.add_widget(Button(text='[color=33ff99]Refresh[/color]', size_hint=(1, 0.15), markup=True,on_release=self.do))
for i in range(11):
self.lay.add_widget(Label(text='', size_hint=(1, 0.15)))
for j in range(11):
self.lay.add_widget(Label(text=str(self.titre[j]),size_hint=(0.2,0.2),markup=True))
long = len(self.data)
for i in range(long):
for j in range(11):
self.lay.add_widget(Label(text=str(self.data[i][j])))
self.add_widget(self.lay)

class Root(BoxLayout):

def __init__(self):
super(Root, self).__init__()
self.orientation = "vertical"
#Window.clearcolor = (0.6, 0.6, 0.6,1)
sm = Manager()

self.add_widget(Nav(sm=sm))
self.add_widget(sm)
self.add_widget(Button(text='refresh',size_hint=(0.2,0.2),on_release=self.refresh))
Window.size = (1500, 900)

def refresh(self,ins):
sm=Manager()
sm.refresh()

class TestApp(App):
def build(App):
return Root()

if __name__ == '__main__':
TestApp().run()









share|improve this question



























    0















    i'm using kivy for building an app screen with 3 screens.
    my main screen ( class Base) is showing data from a SQL request.
    i would like the user to be able to update these data using a button.
    first this class Base is called in the screen manager which is itself called in my root class.
    So my question is , how do i clear the data in my class Base and update it with the new data?



    i tried to clear the data in my class screen manager.
    the refresh function is called from the root class.
    i have the below error:
    'ScreenManager uses remove_widget only for removing Screens'



    from kivy.app import App
    from kivy.uix.screenmanager import ScreenManager, Screen
    from kivy.uix.boxlayout import BoxLayout
    from kivy.uix.gridlayout import GridLayout
    from kivy.uix.button import Button
    from kivy.uix.label import Label
    from sql import runsql2
    from kivy.core.window import Window

    class Manager(ScreenManager):
    def __init__(self):
    super(Manager, self).__init__()

    for i in range(2):
    txt = 'Screen {}'.format(i)
    lbl = Label(text=txt)
    screen = Screen(name=txt)
    screen.add_widget(lbl)
    self.add_widget(screen)

    base=Base('main')
    self.add_widget(base)

    def refresh(self):
    self.clear_widgets(screens='main')
    base=Base('main')
    self.add_widget(base)


    class Nav(GridLayout):

    def __init__(self,sm=None):
    super(Nav, self).__init__()

    self.sm = sm
    self.cols =3
    self.size_hint = (1,0.1)
    self.add_widget(Button(text="Clearing Screen", on_release=self.change))
    self.add_widget(Button(text="Go screen 2", on_release=self.goscreen))
    self.add_widget(Button(text="Quit", on_release=self.quit))

    def change(self, btn):
    #self.sm.current = btn.text
    self.sm.current='main'

    def quit(self,ins):
    exit()

    def goscreen(self,ins):
    self.sm.current='Screen 1'

    class Base(Screen):
    def __init__(self,name):
    super(Base, self).__init__()
    self.lay=GridLayout()
    self.name=name
    self.bout=['[color=33ff99]Refresh[/color]','',"","","","","","","","",""]
    self.data=runsql2()
    self.lay.cols = 11
    self.titre=['[color=ff9900]Market[/color]', '[color=ff9900]B/S[/color]', '[color=ff9900]Volume[/color]', '[color=ff9900]Contract[/color]',
    '[color=ff9900]C/P[/color]', '[color=ff9900]Expiry[/color]', '[color=ff9900]Strike[/color]', '[color=ff9900]Price[/color]',
    '[color=ff9900]Account[/color]', '[color=ff9900]Give up Member[/color]', '[color=ff9900]Allocation Account[/color]']

    #self.lay.add_widget(Button(text='[color=33ff99]Refresh[/color]', size_hint=(1, 0.15), markup=True,on_release=self.do))
    for i in range(11):
    self.lay.add_widget(Label(text='', size_hint=(1, 0.15)))
    for j in range(11):
    self.lay.add_widget(Label(text=str(self.titre[j]),size_hint=(0.2,0.2),markup=True))
    long = len(self.data)
    for i in range(long):
    for j in range(11):
    self.lay.add_widget(Label(text=str(self.data[i][j])))
    self.add_widget(self.lay)

    class Root(BoxLayout):

    def __init__(self):
    super(Root, self).__init__()
    self.orientation = "vertical"
    #Window.clearcolor = (0.6, 0.6, 0.6,1)
    sm = Manager()

    self.add_widget(Nav(sm=sm))
    self.add_widget(sm)
    self.add_widget(Button(text='refresh',size_hint=(0.2,0.2),on_release=self.refresh))
    Window.size = (1500, 900)

    def refresh(self,ins):
    sm=Manager()
    sm.refresh()

    class TestApp(App):
    def build(App):
    return Root()

    if __name__ == '__main__':
    TestApp().run()









    share|improve this question

























      0












      0








      0








      i'm using kivy for building an app screen with 3 screens.
      my main screen ( class Base) is showing data from a SQL request.
      i would like the user to be able to update these data using a button.
      first this class Base is called in the screen manager which is itself called in my root class.
      So my question is , how do i clear the data in my class Base and update it with the new data?



      i tried to clear the data in my class screen manager.
      the refresh function is called from the root class.
      i have the below error:
      'ScreenManager uses remove_widget only for removing Screens'



      from kivy.app import App
      from kivy.uix.screenmanager import ScreenManager, Screen
      from kivy.uix.boxlayout import BoxLayout
      from kivy.uix.gridlayout import GridLayout
      from kivy.uix.button import Button
      from kivy.uix.label import Label
      from sql import runsql2
      from kivy.core.window import Window

      class Manager(ScreenManager):
      def __init__(self):
      super(Manager, self).__init__()

      for i in range(2):
      txt = 'Screen {}'.format(i)
      lbl = Label(text=txt)
      screen = Screen(name=txt)
      screen.add_widget(lbl)
      self.add_widget(screen)

      base=Base('main')
      self.add_widget(base)

      def refresh(self):
      self.clear_widgets(screens='main')
      base=Base('main')
      self.add_widget(base)


      class Nav(GridLayout):

      def __init__(self,sm=None):
      super(Nav, self).__init__()

      self.sm = sm
      self.cols =3
      self.size_hint = (1,0.1)
      self.add_widget(Button(text="Clearing Screen", on_release=self.change))
      self.add_widget(Button(text="Go screen 2", on_release=self.goscreen))
      self.add_widget(Button(text="Quit", on_release=self.quit))

      def change(self, btn):
      #self.sm.current = btn.text
      self.sm.current='main'

      def quit(self,ins):
      exit()

      def goscreen(self,ins):
      self.sm.current='Screen 1'

      class Base(Screen):
      def __init__(self,name):
      super(Base, self).__init__()
      self.lay=GridLayout()
      self.name=name
      self.bout=['[color=33ff99]Refresh[/color]','',"","","","","","","","",""]
      self.data=runsql2()
      self.lay.cols = 11
      self.titre=['[color=ff9900]Market[/color]', '[color=ff9900]B/S[/color]', '[color=ff9900]Volume[/color]', '[color=ff9900]Contract[/color]',
      '[color=ff9900]C/P[/color]', '[color=ff9900]Expiry[/color]', '[color=ff9900]Strike[/color]', '[color=ff9900]Price[/color]',
      '[color=ff9900]Account[/color]', '[color=ff9900]Give up Member[/color]', '[color=ff9900]Allocation Account[/color]']

      #self.lay.add_widget(Button(text='[color=33ff99]Refresh[/color]', size_hint=(1, 0.15), markup=True,on_release=self.do))
      for i in range(11):
      self.lay.add_widget(Label(text='', size_hint=(1, 0.15)))
      for j in range(11):
      self.lay.add_widget(Label(text=str(self.titre[j]),size_hint=(0.2,0.2),markup=True))
      long = len(self.data)
      for i in range(long):
      for j in range(11):
      self.lay.add_widget(Label(text=str(self.data[i][j])))
      self.add_widget(self.lay)

      class Root(BoxLayout):

      def __init__(self):
      super(Root, self).__init__()
      self.orientation = "vertical"
      #Window.clearcolor = (0.6, 0.6, 0.6,1)
      sm = Manager()

      self.add_widget(Nav(sm=sm))
      self.add_widget(sm)
      self.add_widget(Button(text='refresh',size_hint=(0.2,0.2),on_release=self.refresh))
      Window.size = (1500, 900)

      def refresh(self,ins):
      sm=Manager()
      sm.refresh()

      class TestApp(App):
      def build(App):
      return Root()

      if __name__ == '__main__':
      TestApp().run()









      share|improve this question














      i'm using kivy for building an app screen with 3 screens.
      my main screen ( class Base) is showing data from a SQL request.
      i would like the user to be able to update these data using a button.
      first this class Base is called in the screen manager which is itself called in my root class.
      So my question is , how do i clear the data in my class Base and update it with the new data?



      i tried to clear the data in my class screen manager.
      the refresh function is called from the root class.
      i have the below error:
      'ScreenManager uses remove_widget only for removing Screens'



      from kivy.app import App
      from kivy.uix.screenmanager import ScreenManager, Screen
      from kivy.uix.boxlayout import BoxLayout
      from kivy.uix.gridlayout import GridLayout
      from kivy.uix.button import Button
      from kivy.uix.label import Label
      from sql import runsql2
      from kivy.core.window import Window

      class Manager(ScreenManager):
      def __init__(self):
      super(Manager, self).__init__()

      for i in range(2):
      txt = 'Screen {}'.format(i)
      lbl = Label(text=txt)
      screen = Screen(name=txt)
      screen.add_widget(lbl)
      self.add_widget(screen)

      base=Base('main')
      self.add_widget(base)

      def refresh(self):
      self.clear_widgets(screens='main')
      base=Base('main')
      self.add_widget(base)


      class Nav(GridLayout):

      def __init__(self,sm=None):
      super(Nav, self).__init__()

      self.sm = sm
      self.cols =3
      self.size_hint = (1,0.1)
      self.add_widget(Button(text="Clearing Screen", on_release=self.change))
      self.add_widget(Button(text="Go screen 2", on_release=self.goscreen))
      self.add_widget(Button(text="Quit", on_release=self.quit))

      def change(self, btn):
      #self.sm.current = btn.text
      self.sm.current='main'

      def quit(self,ins):
      exit()

      def goscreen(self,ins):
      self.sm.current='Screen 1'

      class Base(Screen):
      def __init__(self,name):
      super(Base, self).__init__()
      self.lay=GridLayout()
      self.name=name
      self.bout=['[color=33ff99]Refresh[/color]','',"","","","","","","","",""]
      self.data=runsql2()
      self.lay.cols = 11
      self.titre=['[color=ff9900]Market[/color]', '[color=ff9900]B/S[/color]', '[color=ff9900]Volume[/color]', '[color=ff9900]Contract[/color]',
      '[color=ff9900]C/P[/color]', '[color=ff9900]Expiry[/color]', '[color=ff9900]Strike[/color]', '[color=ff9900]Price[/color]',
      '[color=ff9900]Account[/color]', '[color=ff9900]Give up Member[/color]', '[color=ff9900]Allocation Account[/color]']

      #self.lay.add_widget(Button(text='[color=33ff99]Refresh[/color]', size_hint=(1, 0.15), markup=True,on_release=self.do))
      for i in range(11):
      self.lay.add_widget(Label(text='', size_hint=(1, 0.15)))
      for j in range(11):
      self.lay.add_widget(Label(text=str(self.titre[j]),size_hint=(0.2,0.2),markup=True))
      long = len(self.data)
      for i in range(long):
      for j in range(11):
      self.lay.add_widget(Label(text=str(self.data[i][j])))
      self.add_widget(self.lay)

      class Root(BoxLayout):

      def __init__(self):
      super(Root, self).__init__()
      self.orientation = "vertical"
      #Window.clearcolor = (0.6, 0.6, 0.6,1)
      sm = Manager()

      self.add_widget(Nav(sm=sm))
      self.add_widget(sm)
      self.add_widget(Button(text='refresh',size_hint=(0.2,0.2),on_release=self.refresh))
      Window.size = (1500, 900)

      def refresh(self,ins):
      sm=Manager()
      sm.refresh()

      class TestApp(App):
      def build(App):
      return Root()

      if __name__ == '__main__':
      TestApp().run()






      python kivy






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 18 hours ago









      eric pariseric paris

      192




      192
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54250462%2fscreen-update-in-screen-manager%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54250462%2fscreen-update-in-screen-manager%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Callistus III

          Ostreoida

          Plistias Cous