@@ -18989,55 +18989,34 @@ onDisplayGene <- function() {
18989
18989
geneLabel <- ttklabel(geneDialog, text = 'Enter the name of the gene you wish to view in detail:')
18990
18990
tkgrid(geneLabel, padx = 10, pady = 5)
18991
18991
18992
+ # Create tclVars for both the entry and dropdown
18993
+ geneEntryVar <- tclVar("")
18994
+ geneDropdownVar <- tclVar("")
18995
+
18992
18996
# Entry box for manual gene name input
18993
- geneEntry <- tkentry(geneDialog, width = 30)
18997
+ geneEntry <- tkentry(geneDialog, textvariable=geneEntryVar, width = 30)
18994
18998
tkgrid(geneEntry, padx = 10, pady = 5)
18995
18999
18996
19000
# Dropdown (combobox) populated with available gene names from species$genes$name
18997
19001
geneNamesList <- species$genes$name # Assuming this is a list of available gene names
18998
19002
18999
- ### Get Threshold from gene_labeling ###
19000
- if (fileFolder[[currentSpectrum]]$file.par$noise_override != -1) {
19001
- threshold <- fileFolder[[currentSpectrum]]$file.par$noise_override
19002
- } else {
19003
- threshold <- fileFolder[[currentSpectrum]]$file.par$noise_multiplier
19003
+ if (length(geneNamesList) == 0) {
19004
+ tkmessageBox(message = "No gene names available.", icon = "error")
19005
+ tkdestroy(geneDialog)
19006
+ return()
19004
19007
}
19005
19008
19006
- ### Filter genes based on the threshold ###
19007
- # Assuming there's a corresponding `species$genes$scores` vector with gene scores
19008
- geneScores <- species$genes$scores # Make sure this vector exists
19009
- filteredGenes <- geneNamesList[geneScores > threshold] # Filter genes above the threshold
19009
+ geneDropdown <- ttkcombobox(geneDialog, textvariable=geneDropdownVar, values = geneNamesList, width = 27)
19010
+ tkgrid(geneDropdown, padx = 10, pady = 5)
19010
19011
19011
- ### Add a Listbox to Display Filtered Gene Names ###
19012
- geneListVar <- tclVar()
19013
- tclObj(geneListVar) <- filteredGenes # Populate the listbox with filtered gene names
19014
-
19015
- geneListbox <- tklistbox(geneDialog, listvariable = geneListVar, selectmode = "single", width = 30, height = 10)
19016
- tkgrid(geneListbox, padx = 10, pady = 5)
19017
-
19018
- # Scrollbar for the listbox
19019
- listScrollbar <- ttkscrollbar(geneDialog, orient = "vertical", command = function(...) tkyview(geneListbox, ...))
19020
- tkconfigure(geneListbox, yscrollcommand = function(...) tkset(listScrollbar, ...))
19021
- tkgrid(listScrollbar, column = 2, row = 4, sticky = "ns")
19022
-
19023
19012
# Function to handle the 'OK' button click
19024
19013
onOK <- function() {
19025
- # Get the gene name from either the entry box, dropdown, or listbox
19026
- geneName <- tclvalue(geneEntry)
19027
-
19028
- if (nchar(geneName) == 0) {
19029
- geneName <- tclvalue(geneDropdown) # Fall back to dropdown selection
19030
- }
19031
-
19032
- # Get the selected item from the listbox if nothing else is selected
19014
+ # Get the gene name from either the entry box or dropdown
19015
+ geneName <- tclvalue(geneEntryVar)
19033
19016
if (nchar(geneName) == 0) {
19034
- selectedIdx <- as.integer(tkcurselection(geneListbox))
19035
- if (length(selectedIdx) > 0) {
19036
- geneName <- filteredGenes[selectedIdx + 1] # Listbox is 0-indexed
19037
- }
19017
+ geneName <- tclvalue(geneDropdownVar) # Fall back to dropdown selection
19038
19018
}
19039
19019
19040
- # Proceed with analysis
19041
19020
if (nchar(geneName) == 0) {
19042
19021
# No gene entered or selected, analyze full proteome
19043
19022
analyze_genes('')
@@ -19065,8 +19044,8 @@ onDisplayGene <- function() {
19065
19044
19066
19045
# Keep focus on the dialog
19067
19046
tkfocus(geneDialog)
19047
+ tcl("update") # Ensure focus and window visibility is updated
19068
19048
}
19069
-
19070
19049
displayGeneButton <- ttkbutton(genePlotTypeFrame, text='Display Single Gene', width=21, command=onDisplayGene)
19071
19050
19072
19051
onDisplayProteome <- function()
0 commit comments