Skip to content

Commit

Permalink
✨ feat: init projects
Browse files Browse the repository at this point in the history
  • Loading branch information
mostypc123 committed Jan 1, 2025
1 parent d80e8d3 commit ae91316
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 3 deletions.
33 changes: 33 additions & 0 deletions src/init_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import main
import os

def xedix_init():
current_dir = main.TextEditor().current_dir

# Change directory using os.system
os.system(f'cd "{current_dir}"')

# Also change the Python script's working directory
os.chdir(current_dir)

# Create XediX Config files
with open("theme.xcfg", "w") as f:
f.write("dark")

with open("xedix.xcfg", "w") as f:
f.write("headerActive:#EDF0F2;")
f.write("headerInactive:#b3d0e4;")

# Create a Gthub Integration Config file
with open("repo.ghicfg", "w") as f:
f.write("")

def python_init():
with open("requirements.txt", "w") as f:
f.write("")

def git_init():
with open(".gitignore", "w") as f:
f.write("")

os.system("git init")
35 changes: 32 additions & 3 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import git_integration
import settings
import github
import init_project

class TextEditor(wx.Frame):
def __init__(self, *args, **kwargs):
Expand All @@ -43,6 +44,8 @@ def __init__(self, *args, **kwargs):
except Exception as e:
pass

current_dir = os.getcwd()

# Bind focus events for dynamic color change
self.Bind(wx.EVT_ACTIVATE, self.on_activate)

Expand Down Expand Up @@ -85,8 +88,11 @@ def on_activate(self, event):
def InitUI(self):
panel = wx.Panel(self)
# panel.SetBackgroundColour("#343947")
icon = wx.Icon('xedixlogo.ico', wx.BITMAP_TYPE_ICO)
self.SetIcon(icon)
try:
icon = wx.Icon('xedixlogo.ico', wx.BITMAP_TYPE_ICO)
self.SetIcon(icon)
except Exception as e:
print(e)

splitter = wx.SplitterWindow(panel)

Expand Down Expand Up @@ -136,7 +142,10 @@ def InitUI(self):
font.PointSize += 5
font.color = wx.Colour(255, 255, 255)
font.bold = True
self.default_message.SetFont(font)
try:
self.default_message.SetFont(font)
except Exception as e:
print(e)

main_vbox = wx.BoxSizer(wx.VERTICAL)
self.main_panel.SetBackgroundColour("#EDF0F2")
Expand Down Expand Up @@ -224,11 +233,17 @@ def CreateMenuBar(self):
customize_item = configMenu.Append(wx.ID_ANY, '&Customize manually\tCtrl+Shift+C', 'Customize the UI')
settings_item = configMenu.Append(wx.ID_ANY, '&Settings', 'Open Settings')

projectMenu = wx.Menu()
init_project_item = projectMenu.Append(wx.ID_ANY, '&Init Project', 'Initialize a new project')
init_python_item = projectMenu.Append(wx.ID_ANY, '&Init Python', 'Initialize a new Python project')
init_git_item = projectMenu.Append(wx.ID_ANY, '&Init Git', 'Initialize a new Git project')

menubar.Append(fileMenu, '&File')
menubar.Append(editMenu, '&Edit')
menubar.Append(toolsMenu,'&Tools')
menubar.Append(configMenu, '&Config')
menubar.Append(helpMenu, '&Help')
menubar.Append(projectMenu, '&Project')
# Define minsize
self.SetMenuBar(menubar)

Expand All @@ -242,6 +257,9 @@ def CreateMenuBar(self):
self.Bind(wx.EVT_MENU, self.gcommit, commit_item)
self.Bind(wx.EVT_MENU, self.OnExit, exit_item)
self.Bind(wx.EVT_MENU, self.OnCut, cut_item)
self.Bind(wx.EVT_MENU, self.ginit, init_git_item)
self.Bind(wx.EVT_MENU, self.pinit, init_python_item)
self.Bind(wx.EVT_MENU, self.xinit, init_project_item)
self.Bind(wx.EVT_MENU, self.OnCopy, copy_item)
self.Bind(wx.EVT_MENU, self.OnOpenFolder, folder_item)
self.Bind(wx.EVT_MENU, self.OnConfig, settings_item)
Expand All @@ -257,6 +275,15 @@ def CreateMenuBar(self):

def gcommit(self, event):
git_integration.commit()

def ginit(self, event):
init_project.git_init()

def pinit(self, event):
init_project.python_init()

def xinit(self, event):
init_project.xedix_init()

# The following functions are opening webpages
def About(self, event):
Expand Down Expand Up @@ -304,6 +331,8 @@ def OnOpenFolder(self, event):
# Populate the file list with files from the new directory
self.PopulateFileList()

self.current_dir = path

dlg.Destroy()

def RequirementsGeneration(self, event):
Expand Down

0 comments on commit ae91316

Please sign in to comment.