Skip to content

Commit c4e8616

Browse files
finalized it for now
1 parent bdf05bb commit c4e8616

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

lobsterpygui

1.15 KB
Binary file not shown.

src/main.cpp

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,67 @@
66
// let's see what's left of the c++ skills...
77
// compile with g++ -o lobsterpygui src/main.cpp $(pkg-config --cflags --libs gtk+-3.0)
88

9-
// Callback function for the button click event
9+
// Callback function for the button click event, could put that in its own header main.hpp
1010
void on_button_clicked(GtkWidget *widget, gpointer data)
1111
{
1212
const char* command = static_cast<const char*>(data);
1313
const char* subplotdos = "plotdos";
14+
const char* subplot = "plot";
1415
std::string element;
15-
char tmp[100];
16+
int bond_num;
17+
char tmppd[100];
18+
char tmpp[100];
1619
if (strstr(command, subplotdos) != NULL)
1720
{
1821
g_print("Enter element: ");
1922
std::cin >> element;
20-
strcpy(tmp, command);
21-
strcat(tmp, " --element ");
22-
strcat(tmp, element.c_str());
23-
command = tmp;
23+
strcpy(tmppd, command);
24+
strcat(tmppd, " --element ");
25+
strcat(tmppd, element.c_str());
26+
command = tmppd;
27+
}
28+
if (strstr(command, subplot) != NULL)
29+
{
30+
g_print("Enter bond number: ");
31+
std::cin >> bond_num;
32+
std::string bond_num_str = " " + std::to_string(bond_num);
33+
strcpy(tmpp, command);
34+
strcat(tmpp, bond_num_str.c_str());
35+
command = tmpp;
2436
}
2537
g_print("%s\n", command);
2638
std::system(command);
2739
g_print("finished\n");
2840
}
2941

30-
3142
int main(int argc, char *argv[])
3243
{
33-
std::cout << "LobsterPyGUI written by Christina Ertural (currently in a very basic mode)" << std:: endl;
44+
std::cout << "LobsterPyGUI written by Christina Ertural for very beginners to get familiar with LOBSTER and LobsterPy!" << std:: endl;
3445

3546
// Initialize GTK+
3647
gtk_init(&argc, &argv);
48+
GtkWidget *window;
3749

3850
// Create the main window
39-
GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
40-
gtk_window_set_title(GTK_WINDOW(window), "LobsterPyGUI Prototype");
51+
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
52+
gtk_window_set_title(GTK_WINDOW(window), "LobsterPyGUI: Very basic LobsterPy features");
53+
//gtk_window_set_keep_above(GTK_WINDOW(window), TRUE);
54+
gtk_window_present (GTK_WINDOW (window));
4155
g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
4256
GtkWidget *box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
4357
gtk_container_add(GTK_CONTAINER(window), box);
4458

4559
// Create a button and connect it to the callback function
4660
const char* button_commands[] =
4761
{
62+
"lobsterpy description",
63+
"lobsterpy calc-description",
64+
"lobsterpy autoplot",
65+
"lobsterpy autoplotia",
4866
"lobsterpy createinputs",
49-
"lobsterpy autoplot",
5067
"lobsterpy plotdos",
68+
"lobsterpy plot-icohps-distances",
69+
"lobsterpy plot"
5170
// Add more commands for additional buttons if needed
5271
};
5372

0 commit comments

Comments
 (0)