from juce_init import START_JUCE_COMPONENT import popsicle as juce class SidePanel(juce.Component): backgroundColour = juce.Colours.lightblue textColour = juce.Colours.black robots = [] robotsLabel = juce.Label("", "Выберите робота") robotsRadio = [] robotsControls = [robotsLabel] + robotsRadio robotButtonsId = 1001 def __init__(self, robots=[]): super().__init__() self.robots = robots for r in self.robots: self.robotsRadio.append( juce.ToggleButton(r["name"]), ) self.robotsControls = [self.robotsLabel] + self.robotsRadio for s in self.robotsControls: self.addAndMakeVisible(s) for s in self.robotsRadio: s.setRadioGroupId(self.robotButtonsId, juce.dontSendNotification) s.onClick = self.updateToggleState s.setClickingTogglesState(True) def paint(self, g: juce.Graphics): g.fillAll(self.backgroundColour) for i, s in enumerate(self.robotsControls): s.setColour(s.textColourId, self.textColour) if hasattr(s, "tickDisabledColourId"): s.setColour(s.tickColourId, self.textColour) s.setColour(s.tickDisabledColourId, self.textColour) s.setBounds(10 if i == 0 else 20, (i * 20), self.getWidth() - 20, 20) def updateToggleState(self): for i, s in enumerate(self.robotsRadio): if s.getToggleState() == True: print(self.robots[i]) break; class MainPanel(juce.Component): sliders = [] def __init__(self): super().__init__() for _ in range(5): slider = juce.Slider() slider.setTextBoxStyle( juce.Slider.TextEntryBoxPosition.NoTextBox, True, 0, 0 ) self.sliders.append(slider) self.addAndMakeVisible(slider) def paint(self, g): g.fillAll(juce.Colours.hotpink) class MainContentComponent(juce.Component): def __init__(self, robots): super().__init__() self.rightPanel = SidePanel(robots) self.mainPanel = MainPanel() self.addAndMakeVisible(self.rightPanel) self.addAndMakeVisible(self.mainPanel) self.setSize(800, 600) # self.setResizable(False, False) def paint(self, g): g.fillAll( self.getLookAndFeel().findColour(juce.ResizableWindow.backgroundColourId) ) def resized(self): bounds = self.getLocalBounds() self.rightPanel.setBounds(bounds.removeFromRight(self.proportionOfWidth(0.25))) self.mainPanel.setBounds(bounds) if __name__ == "__main__": START_JUCE_COMPONENT(MainContentComponent, name="ROBOT GUI")