Python Forum
UI ComboBox in DatagridColumn - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: UI ComboBox in DatagridColumn (/thread-20791.html)



UI ComboBox in DatagridColumn - BollerwagenIng - Aug-30-2019

Hello,

I crate a DataGrid and I want to insert for every row in the third column a ComboBox. I am so far til now:

def getUIContent():
   my_toolProperty = sdk.ToolPropertyContainer()   

   # Define UI
   my_toolProperty.ToolPropertyContent = getCustomToolPropertyContent()
   
   # Update Grid
   UpdateDataGridData()
   
   return my_toolProperty
def getCustomToolPropertyContent():

   # Create a Grid
   my_Grid = WPFControls.Grid()

   # Add 1 Row and One Column
   my_Grid.RowDefinitions.Add(WPFControls.RowDefinition())
   my_Grid.ColumnDefinitions.Add(WPFControls.ColumnDefinition())
  
   # Create a DataGrid
   global myDataGrid
   myDataGrid = WPFControls.DataGrid()
   
   # global myComboBox
   myComboBox = WPFControls.DataGridComboBoxCollumn()

   
   # Add the DataGrid to the Grid 
   my_Grid.Children.Add(myDataGrid)

   # Return the Grid   
   return my_Grid

# def UpdateData (it's only the Path of api / not important)

@apex_sdk.errorhandler
def UpdateDataGridView():

   # Retrieve grid results
   grid = sdk.getScriptFunctionReturnData()

   # Create table
   data_table = WPFData.DataTable("Contents")
   data_table.Columns.Add("Prename")
   data_table.Columns.Add("Last Name")
   
   # Add data to the table for each name
   parts = grid['Name']
   for name in names:      
      data_table.Rows.Add(part['prename'], part['lastname'])
   
   # Set the IetmsSource for the data grid to the DataTable 
   myDataGrid.ItemsSource = data_table.DefaultView
   # myDataGrid.ItemsSource = myComboBox     ??? 
   
   # Position the DataGrid in the first row, column of the Grid
   WPFControls.Grid.SetRow(myDataGrid, 0)
   WPFControls.Grid.SetColumn(myDataGrid, 0)



RE: UI ComboBox in DatagridColumn - Denni - Sep-03-2019

Two things (1) a MRE (Minimal Reproducible Example) will help you get a faster answer -- aka if one can just copy and paste what you provided and run it the answers are much faster in coming and more accurate in their response.

(2) What are you using for your Gui -- Tkinter, PyQt, etc... this should be in your subject so that folks that are in the know about what you are asking about know that this is a item they can reply to