Combine RBA::InputDialog.get_string and RBA::InputDialog::ask_item

edited January 2021 in Ruby Scripting

Is there a way too combine RBA::InputDialog.get_string and RBA::InputDialog::ask_item
into one dialog window

Comments

  • @tagger5896 The only way is to create a custom dialog.

    You'll need some Qt knowledge for this purpose. A good starting point is the "Qt dialog sample" you can select when you create a new macro in the IDE.

    Matthias

  • Matthias,

    Thanks figured out

     dialog = QDialog.new(Application.instance.main_window);
     dialog.resize(400,200)
     dialog.windowTitle = "Test Box";
     qt_layout = QVBoxLayout::new(dialog);
     dialog.setLayout(qt_layout)
    
    
     # Define the Net combo box
     combo_net = QComboBox.new(dialog)
     unique_nets.each { |p|
           combo_net.addItem(p) #nets[0] will be selected initially
     }
    
    # Define the Layers combo box
     combo_layers = QComboBox.new(dialog)
          in_lyp.each { |p|
          combo_layers.addItem(p) # layers[0] will be selected initially
           }
    
     # Add the combo box to choose net
     qt_layout.addWidget(combo_net)
     # Add the combo box to choose layers    
     qt_layout.addWidget(combo_layers)
    
      # OK button
      buttonOK = QPushButton.new(dialog)
      qt_layout.addWidget(buttonOK)
      buttonOK.text = " OK "
      buttonOK.clicked do 
           dialog.accept()
     end
    
     #Get Result of Combo box
      result = dialog.exec
      result == 1 ? accepted = true : accepted = false
      input = combo_net.currentText + "." + combo_layers.currentText
      puts input
    
  • Very good! That's example what I meant.

    Thanks for sharing the code! :)

    Warm regards,

    Matthias

  • Matthias

    TYVM slowing wrapping my head around Ruby and python

Sign In or Register to comment.