def changeColorGUI(ncolor): global color, alpha, colorTF alpha = slider.getValue() * 255 / 100 color = Color(ncolor.getRed(), ncolor.getGreen(), ncolor.getBlue(), alpha) colorTF.setText("") colorTF.setText(color.toString()) # To avoid transparency to the before color on the textField colorTF.setBackground(Color(255,255,255,255)) colorTF.setBackground(color) print color print alpha print colorTF.getBackground()
def getGUI(sym_dict): global frame, outCheckbox, fillCheckbox, slider, colorTF, widthTF frame = JFrame("Border Symbology", defaultCloseOperation=JFrame.DISPOSE_ON_CLOSE, bounds=(100, 100, 450, 200), layout=FlowLayout(), resizable=0) colorL = JLabel('Color: ') colorTF = JTextField(20) color = sym_dict["color"] color = Color(color.getRed(), color.getGreen(), color.getBlue(), sym_dict["alpha"]) colorTF.setBackground(color) colorTF.setText(color.toString()) colorB = JButton('...', actionPerformed=colorChooser) frame.add(colorL) frame.add(colorTF) frame.add(colorB) widthL = JLabel('Width: ') widthTF = JTextField(3) widthTF.setText(str(sym_dict["width"])) frame.add(widthL) frame.add(widthTF) alphaL = JLabel('Transparency: ') frame.add(alphaL) # Create a horizontal slider with min=0, max=100, value=50 slider = JSlider() slider.setPreferredSize(Dimension(200, 50)) slider.setValue(sym_dict["alpha"]*100/255) slider.setMajorTickSpacing(25) slider.setMinorTickSpacing(5) slider.setPaintTicks(1) slider.setPaintLabels(1) applyButton = JButton("Apply", actionPerformed=action) acceptButton = JButton("Accept", actionPerformed=accept) frame.add(slider) frame.add(applyButton) frame.add(acceptButton) frame.show()