@@ -18980,6 +18980,68 @@ ps <- function(dispPane='co'){
18980
18980
# }
18981
18981
# displayGeneButton <- ttkbutton(genePlotTypeFrame, text='Display Single Gene', width=21, command=onDisplayGene)
18982
18982
18983
+ # onDisplayGene <- function() {
18984
+ # # Generate a temporary dialog window
18985
+ # geneDialog <- tktoplevel()
18986
+ # tkwm.title(geneDialog, "Gene Name Entry")
18987
+
18988
+ # # Instruction label
18989
+ # geneLabel <- ttklabel(geneDialog, text = 'Enter the name of the gene you wish to view in detail:')
18990
+ # tkgrid(geneLabel, padx = 10, pady = 5)
18991
+
18992
+ # # Entry box for manual gene name input
18993
+ # geneEntry <- tkentry(geneDialog, width = 30)
18994
+ # tkgrid(geneEntry, padx = 10, pady = 5)
18995
+
18996
+ # # Dropdown (combobox) populated with available gene names from species$genes$name
18997
+ # geneNamesList <- species$genes$name # Assuming this is a list of available gene names
18998
+ # geneDropdown <- ttkcombobox(geneDialog, values = geneNamesList, width = 27)
18999
+ # tkgrid(geneDropdown, padx = 10, pady = 5)
19000
+
19001
+ # # Function to handle the 'OK' button click
19002
+ # onOK <- function() {
19003
+ # # Get the gene name from either the entry box or dropdown
19004
+ # geneName <- tclvalue(geneEntry)
19005
+ # if (nchar(geneName) == 0) {
19006
+ # geneName <- tclvalue(geneDropdown) # Fall back to dropdown selection
19007
+ # }
19008
+
19009
+ # if (nchar(geneName) == 0) {
19010
+ # # No gene entered or selected, analyze full proteome
19011
+ # analyze_genes('')
19012
+ # } else if (geneName %in% species$genes$name) {
19013
+ # # Valid gene name, analyze the selected gene
19014
+ # analyze_genes(geneName)
19015
+ # } else {
19016
+ # # Invalid gene name, display error message
19017
+ # log_message(paste0(geneName, ' is not a valid gene of ', species$name))
19018
+ # }
19019
+
19020
+ # tkdestroy(geneDialog) # Close the dialog box
19021
+ # }
19022
+
19023
+ # # OK button
19024
+ # okButton <- ttkbutton(geneDialog, text = 'OK', command = onOK)
19025
+ # tkgrid(okButton, padx = 10, pady = 10)
19026
+
19027
+ # # Cancel button
19028
+ # onCancel <- function() {
19029
+ # tkdestroy(geneDialog) # Close the dialog box without action
19030
+ # }
19031
+ # cancelButton <- ttkbutton(geneDialog, text = 'Cancel', command = onCancel)
19032
+ # tkgrid(cancelButton, padx = 10, pady = 10)
19033
+
19034
+ # # Keep focus on the dialog
19035
+ # tkfocus(geneDialog)
19036
+ # }
19037
+ # displayGeneButton <- ttkbutton(genePlotTypeFrame, text='Display Single Gene', width=21, command=onDisplayGene)
19038
+
19039
+ # onDisplayProteome <- function()
19040
+ # {
19041
+ # analyze_genes('')
19042
+ # }
19043
+ #displayGenomeButton <- ttkbutton(genePlotTypeFrame, text='Display Full Proteome', width=21, command=onDisplayProteome)
19044
+
18983
19045
onDisplayGene <- function() {
18984
19046
# Generate a temporary dialog window
18985
19047
geneDialog <- tktoplevel()
@@ -18989,21 +19051,32 @@ onDisplayGene <- function() {
18989
19051
geneLabel <- ttklabel(geneDialog, text = 'Enter the name of the gene you wish to view in detail:')
18990
19052
tkgrid(geneLabel, padx = 10, pady = 5)
18991
19053
19054
+ # Create tclVars for both the entry and dropdown
19055
+ geneEntryVar <- tclVar("")
19056
+ geneDropdownVar <- tclVar("")
19057
+
18992
19058
# Entry box for manual gene name input
18993
- geneEntry <- tkentry(geneDialog, width = 30)
19059
+ geneEntry <- tkentry(geneDialog, textvariable=geneEntryVar, width = 30)
18994
19060
tkgrid(geneEntry, padx = 10, pady = 5)
18995
19061
18996
19062
# Dropdown (combobox) populated with available gene names from species$genes$name
18997
19063
geneNamesList <- species$genes$name # Assuming this is a list of available gene names
18998
- geneDropdown <- ttkcombobox(geneDialog, values = geneNamesList, width = 27)
19064
+
19065
+ if (length(geneNamesList) == 0) {
19066
+ tkmessageBox(message = "No gene names available.", icon = "error")
19067
+ tkdestroy(geneDialog)
19068
+ return()
19069
+ }
19070
+
19071
+ geneDropdown <- ttkcombobox(geneDialog, textvariable=geneDropdownVar, values = geneNamesList, width = 27)
18999
19072
tkgrid(geneDropdown, padx = 10, pady = 5)
19000
19073
19001
19074
# Function to handle the 'OK' button click
19002
19075
onOK <- function() {
19003
19076
# Get the gene name from either the entry box or dropdown
19004
- geneName <- tclvalue(geneEntry )
19077
+ geneName <- tclvalue(geneEntryVar )
19005
19078
if (nchar(geneName) == 0) {
19006
- geneName <- tclvalue(geneDropdown ) # Fall back to dropdown selection
19079
+ geneName <- tclvalue(geneDropdownVar ) # Fall back to dropdown selection
19007
19080
}
19008
19081
19009
19082
if (nchar(geneName) == 0) {
@@ -19033,14 +19106,10 @@ onDisplayGene <- function() {
19033
19106
19034
19107
# Keep focus on the dialog
19035
19108
tkfocus(geneDialog)
19109
+ tcl("update") # Ensure focus and window visibility is updated
19036
19110
}
19037
19111
displayGeneButton <- ttkbutton(genePlotTypeFrame, text='Display Single Gene', width=21, command=onDisplayGene)
19038
-
19039
- onDisplayProteome <- function()
19040
- {
19041
- analyze_genes('')
19042
- }
19043
- displayGenomeButton <- ttkbutton(genePlotTypeFrame, text='Display Full Proteome', width=21, command=onDisplayProteome)
19112
+
19044
19113
19045
19114
##add widgets to fileFrame
19046
19115
tkgrid(onedFileFrame, column=1, row=1, sticky='nswe', pady=c(6, 4), padx=8)
0 commit comments