我不确定我的猕猴桃和图形问题是否与this issue有关,或者我做错了什么。这是我的分钟

主文件:

#! /usr/bin/env python
from math import sin

"""
Activate the touch keyboard. It is important that this part is on top
because the global config should be initiated first.
"""
from kivy.config import Config
Config.set('kivy', 'keyboard_mode', 'multi')

from kivy.app import App
# The Builder is used to define the main interface.
from kivy.lang import Builder
# use the screen manager to switch between screens
from kivy.uix.screenmanager import ScreenManager, Screen

from kivy.garden.graph import Graph, MeshLinePlot
from kivy.utils import get_color_from_hex as rgb


class MainScreen(Screen):
    pass


class DataScreen(Screen):
    def __init__(self, **kwargs):
        super(DataScreen, self).__init__(**kwargs)
        graph_theme = {'label_options': {'color': rgb('595959'), 'bold': False},
                       'background_color': rgb('DBE49A'),
                       'tick_color': rgb('999999'),
                       'border_color': rgb('808080')}

        self.graph = Graph(xlabel='X', ylabel='Y', x_ticks_minor=5,
                      x_ticks_major=25, y_ticks_major=1,
                      y_grid_label=True, x_grid_label=True, padding=5,
                      x_grid=True, y_grid=True, xmin=-0, xmax=100, ymin=-1, ymax=1,
                           **graph_theme)
        self.add_widget(self.graph)

    def plot_data(self):
        plot = MeshLinePlot(color=[1, 1, 0, 1])
        plot.points = [(x, sin(x / 10.)) for x in range(0, 101)]
        self.graph.add_plot(plot)


class MyApp(App):
    """
    The settings App is the main app of the pHBot application.
    It is initiated by kivy and contains the functions defining the main interface.
    """


    def build(self):
        """
        This function initializes the app interface and has to be called "build(self)".
        It returns the user interface defined by the Builder.
        """
        Builder.load_file('phapp.kv')
        sm = ScreenManager()
        sm.add_widget(MainScreen())
        sm.add_widget(DataScreen())
        # returns the user interface defined by the Builder
        return sm


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


奇异果文件:

<MainScreen>:
    name: 'main'
    BoxLayout:
        orientation: 'vertical'
        Button:
            text: 'Go to data'
            font_size: 40
            on_release: app.root.current = 'data'
        Button:
            text: 'Exit'
            font_size: 40
            on_release: app.stop()

<DataScreen>:
    name: 'data'
    BoxLayout:
        orientation: 'vertical'
        Graph:
            size_hint_y: 0.9
        Button:
            size_hint: (1, 0.1)
            text: 'Start plotting data'
            font_size: 30
            on_release: root.plot_data()
        Button:
            size_hint: (1, 0.1)
            text: 'Back to main menu'
            font_size: 30
            on_release: app.root.current = 'main'


有什么想法为什么我的情节没有出现吗?

最佳答案

Github的大多数人问了同样的问题,感谢@tshirtman,提供了following answer


  与@tshirtman聊天后,他发现问题出在
  stencilbuffer并通过更改图形模块init.py的第139行
  至:

self._fbo = Fbo(size=self.size, with_stencilbuffer=False)

  
  在我的示例中这将是可见的,但随后会出现许多问题
  具有图表的新功能(SmoothLinePlot)。


链接:https://github.com/kivy-garden/garden.graph/issues/7

关于python - kivy:情节和屏幕管理器;情节没有出现,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40347303/

10-12 19:55