Skip to content

Commit 4eb4292

Browse files
authored
Update digestR.R
1 parent e8e947c commit 4eb4292

File tree

1 file changed

+79
-10
lines changed

1 file changed

+79
-10
lines changed

R/digestR.R

+79-10
Original file line numberDiff line numberDiff line change
@@ -18980,6 +18980,68 @@ ps <- function(dispPane='co'){
1898018980
# }
1898118981
# displayGeneButton <- ttkbutton(genePlotTypeFrame, text='Display Single Gene', width=21, command=onDisplayGene)
1898218982

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+
1898319045
onDisplayGene <- function() {
1898419046
# Generate a temporary dialog window
1898519047
geneDialog <- tktoplevel()
@@ -18989,21 +19051,32 @@ onDisplayGene <- function() {
1898919051
geneLabel <- ttklabel(geneDialog, text = 'Enter the name of the gene you wish to view in detail:')
1899019052
tkgrid(geneLabel, padx = 10, pady = 5)
1899119053

19054+
# Create tclVars for both the entry and dropdown
19055+
geneEntryVar <- tclVar("")
19056+
geneDropdownVar <- tclVar("")
19057+
1899219058
# Entry box for manual gene name input
18993-
geneEntry <- tkentry(geneDialog, width = 30)
19059+
geneEntry <- tkentry(geneDialog, textvariable=geneEntryVar, width = 30)
1899419060
tkgrid(geneEntry, padx = 10, pady = 5)
1899519061

1899619062
# Dropdown (combobox) populated with available gene names from species$genes$name
1899719063
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)
1899919072
tkgrid(geneDropdown, padx = 10, pady = 5)
1900019073

1900119074
# Function to handle the 'OK' button click
1900219075
onOK <- function() {
1900319076
# Get the gene name from either the entry box or dropdown
19004-
geneName <- tclvalue(geneEntry)
19077+
geneName <- tclvalue(geneEntryVar)
1900519078
if (nchar(geneName) == 0) {
19006-
geneName <- tclvalue(geneDropdown) # Fall back to dropdown selection
19079+
geneName <- tclvalue(geneDropdownVar) # Fall back to dropdown selection
1900719080
}
1900819081

1900919082
if (nchar(geneName) == 0) {
@@ -19033,14 +19106,10 @@ onDisplayGene <- function() {
1903319106

1903419107
# Keep focus on the dialog
1903519108
tkfocus(geneDialog)
19109+
tcl("update") # Ensure focus and window visibility is updated
1903619110
}
1903719111
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+
1904419113

1904519114
##add widgets to fileFrame
1904619115
tkgrid(onedFileFrame, column=1, row=1, sticky='nswe', pady=c(6, 4), padx=8)

0 commit comments

Comments
 (0)