Skip to content

Commit fc62ea1

Browse files
authored
Update digestR.R
1 parent 027e825 commit fc62ea1

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

R/digestR.R

+17-11
Original file line numberDiff line numberDiff line change
@@ -19049,30 +19049,37 @@ onDisplayGene <- function() {
1904919049
geneEntry <- tkentry(geneDialog, width = 30)
1905019050
tkgrid(geneEntry, padx = 10, pady = 5)
1905119051

19052-
# Listbox to display the available gene names from species$genes$name
19052+
# Dropdown (combobox) populated with available gene names from species$genes$name
1905319053
geneNamesList <- species$genes$name # Assuming this is a list of available gene names
19054-
geneListVar <- tclVar() # Variable to store the listbox data
19055-
tclObj(geneListVar) <- geneNamesList
19054+
geneDropdown <- ttkcombobox(geneDialog, values = geneNamesList, width = 27)
19055+
tkgrid(geneDropdown, padx = 10, pady = 5)
19056+
19057+
### Add a Listbox to Display Gene Names ###
19058+
geneListVar <- tclVar()
19059+
tclObj(geneListVar) <- geneNamesList # Populate the listbox with gene names
1905619060

19057-
# Create listbox for gene names
1905819061
geneListbox <- tklistbox(geneDialog, listvariable = geneListVar, selectmode = "single", width = 30, height = 10)
1905919062
tkgrid(geneListbox, padx = 10, pady = 5)
1906019063

1906119064
# Scrollbar for the listbox
1906219065
listScrollbar <- ttkscrollbar(geneDialog, orient = "vertical", command = function(...) tkyview(geneListbox, ...))
1906319066
tkconfigure(geneListbox, yscrollcommand = function(...) tkset(listScrollbar, ...))
19064-
tkgrid(listScrollbar, column = 2, row = 3, sticky = "ns")
19065-
19067+
tkgrid(listScrollbar, column = 2, row = 4, sticky = "ns")
19068+
1906619069
# Function to handle the 'OK' button click
1906719070
onOK <- function() {
19068-
# Get the gene name from the entry box if available
19071+
# Get the gene name from either the entry box, dropdown, or listbox
1906919072
geneName <- tclvalue(geneEntry)
1907019073

19071-
# If no entry, check the listbox selection
19074+
if (nchar(geneName) == 0) {
19075+
geneName <- tclvalue(geneDropdown) # Fall back to dropdown selection
19076+
}
19077+
19078+
# Get the selected item from the listbox if nothing else is selected
1907219079
if (nchar(geneName) == 0) {
1907319080
selectedIdx <- as.integer(tkcurselection(geneListbox))
1907419081
if (length(selectedIdx) > 0) {
19075-
geneName <- geneNamesList[selectedIdx + 1] # Listbox is 0-indexed, hence the +1
19082+
geneName <- geneNamesList[selectedIdx + 1] # Listbox is 0-indexed
1907619083
}
1907719084
}
1907819085

@@ -19106,8 +19113,7 @@ onDisplayGene <- function() {
1910619113
tkfocus(geneDialog)
1910719114
}
1910819115

19109-
# Create a button to display the dialog
19110-
displayGeneButton <- ttkbutton(genePlotTypeFrame, text = 'Display Single Gene', width = 21, command = onDisplayGene)
19116+
displayGeneButton <- ttkbutton(genePlotTypeFrame, text='Display Single Gene', width=21, command=onDisplayGene)
1911119117

1911219118
onDisplayProteome <- function()
1911319119
{

0 commit comments

Comments
 (0)