Python Forum
[PyQt] saving text file by FileDialog option
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] saving text file by FileDialog option
#8
And that is because your not owning the output -- create a function that represents a line -- within this function map out the elements of that line such as the following (note the following is pseudo code you will need to translate that into working code):
#These would be the Headers
ColIdx = 0.1
For Each ItmId in HdrItem: 
   RowElements[ColIdx] = HdrItem[ItmId]
   ColIdx += 0.1

MaxCol = ColIdx -= 0.1
ColIdx = 0.1
RowIdx = 1
For Each RowId in DataFeed:
   RowElements[(RowId+ColIdx)] = DataFeed[RowId]
   ColIdx += 0.1
   if ColIdx > MaxCol:
      RowIdx += 1
      ColIdx = 0.1

# This gets the maximum width of each column
for each RowCol in RowElements:
   Col = ConvertRowColtoCol(RowCol)
   if ColWidth[Col] < len(RowElements[RowCol]):
      ColWidth[Col] = len(RowElements[RowCol])

# Now using these 2 Dictionaries you build a string output from them such that
RowIdx = 0
for each RowCol in RowElements:
   Col = ConvertRowColtoCol(RowCol)
   ColWid = ColWidth[Col]
   Row += CenterCol(RowElements[RowCol],ColWid)
   if Col == MaxCols:
       RowOut[RowIdx] = Row
       Row = ''
       RowIdx += 1

for each Row in RowOut:
   OutputRowToFile(Row)
Reply


Messages In This Thread
RE: saving text file by FileDialog option - by Denni - Feb-10-2020, 05:31 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] Saving file to html or pdf stopped working in PyQt6 ejKDE 4 851 Mar-12-2024, 07:45 PM
Last Post: ejKDE
  [Tkinter] filedialog, open a file error liketocode 4 3,627 Dec-07-2022, 10:51 PM
Last Post: liketocode
  [Tkinter] logical error - saving file rwahdan 4 2,298 Jul-01-2021, 12:59 PM
Last Post: rwahdan
  [Tkinter] Exclude hidden file, filedialog.askopenfile red380sl 1 3,248 Dec-01-2020, 07:04 PM
Last Post: DT2000
  [Tkinter] Unable to save filepath to config.ini file using filedialog.askopenfilename JackMack118 10 5,181 Dec-29-2019, 08:12 PM
Last Post: JackMack118
  Part of code is adding extra new line when saving to text file. lovepeace 9 5,269 Aug-24-2019, 12:52 PM
Last Post: lovepeace
  Update value selected in option menu when select an item from text box klllmmm 2 5,123 Jun-06-2019, 04:51 AM
Last Post: klllmmm
  tkinter filedialog and pickle - custom icon question. kim07133 0 2,816 Jan-08-2018, 12:10 PM
Last Post: kim07133
  [Tkinter] filedialog. FULL SCREEN issac_n 0 3,203 Dec-05-2017, 07:33 AM
Last Post: issac_n

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020