<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Buğra Özden]]></title><description><![CDATA[Buğra Özden]]></description><link>https://bugraozden.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/6b070170ac9d62f1b7afcacd/28c0541e-9201-41ba-9848-cbb7b34897bb.png</url><title>Buğra Özden</title><link>https://bugraozden.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Thu, 26 Nov 2026 11:30:42 GMT</lastBuildDate><atom:link href="https://bugraozden.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Build a CSV viewer desktop app in Python, without HTML or JavaScript]]></title><description><![CDATA[A walk through a 77-line example: a window, the file dialog of the system, the csv module and a table that stays fast with 100,000 rows.]]></description><link>https://bugraozden.hashnode.dev/build-a-csv-viewer-desktop-app-in-python-without-html-or-javascript</link><guid isPermaLink="true">https://bugraozden.hashnode.dev/build-a-csv-viewer-desktop-app-in-python-without-html-or-javascript</guid><category><![CDATA[Python]]></category><category><![CDATA[GUI]]></category><category><![CDATA[desktop]]></category><category><![CDATA[Tutorial]]></category><dc:creator><![CDATA[Buğra Özden]]></dc:creator><pubDate>Wed, 25 Nov 2026 16:00:24 GMT</pubDate><content:encoded><![CDATA[<p>I'm Buğra Özden, and I made OzdenUI, a small Python library for desktop windows. In this post I walk through one of its examples, a CSV viewer, step by step. You write only Python: no HTML, no JavaScript, no server.</p>
<p>First, what it is not yet: OzdenUI is v0.1 and experimental. I test it on macOS and Windows; Linux is not tested yet. It is new and has one author. If that rules it out for you, read "When Tkinter is still the better choice" near the end.</p>
<h2>Who this is for</h2>
<p>You write Python scripts for yourself, your office or your lab: a file tool, a report, a small in-house app. When a script needs a window, you reach for Tkinter, CustomTkinter or FreeSimpleGUI. I wanted ready parts with a modern look (tables, dialogs, charts) without learning the web.</p>
<p>How it works: the window is the web view of the system (WebKit on macOS, WebView2 on Windows), opened by pywebview. The page inside it holds my UI kit, basic.js and its components; the package carries them (about 3 MB, no internet needed). You never touch that page. Every object you make in Python sends commands to it.</p>
<h2>What we build</h2>
<p><img src="https://bug7a.github.io/ozdenui-python/images/csv_viewer.webp" alt="The CSV viewer window: a title, the buttons " /></p>
<p>It opens with a sample of eight cities. "Open a CSV" shows the file dialog of your system. "100000 rows" fills the table with 100,000 rows made in Python. A click on a row writes that row under the table. The whole program is 77 lines: <code>examples/csv_viewer.py</code> in the repository.</p>
<h2>Step 1: install</h2>
<pre><code>pip install ozdenui
</code></pre>
<p>It needs Python 3.9 or newer, and its only dependency is pywebview. On a Mac with the Python of the system, upgrade pip first (<code>python3 -m pip install --upgrade pip</code>): its old pip fails to build a part of pywebview. On Windows the window needs the WebView2 runtime, which most computers have.</p>
<h2>Step 2: the window</h2>
<p>The program starts at its last two lines:</p>
<pre><code class="language-python">if __name__ == "__main__":
    App(start, title="CSV viewer", size=(900, 640)).run()
</code></pre>
<p><code>App</code> is the window. When it is ready, it calls <code>start(page)</code>, which makes the objects. <code>.run()</code> opens the window and returns when it is closed.</p>
<p>The top of the file has the imports and a few named numbers. <code>csv</code> is the standard library:</p>
<pre><code class="language-python">import csv

from ozdenui import App, Box, HGroup, Label, SmartButton, SmartTable, Toast, VGroup, open_file

PAGE_COLOR = "#F4F5F7"
TEXT_SOFT = "#5A6270"
TABLE_WIDTH = 820
TABLE_HEIGHT = 400
COLUMN_WIDTH = 170
MANY_ROWS = 100000
</code></pre>
<p>Under them, <code>SAMPLE</code> is a list of eight dicts, and <code>view = {}</code> keeps the objects that the functions need later.</p>
<h2>Step 3: the layout</h2>
<pre><code class="language-python">def start(page):
    page.color = PAGE_COLOR
    with VGroup(gap=14, padding=30, align="left top"):
        with HGroup(hug=True, gap=14, align="left center"):
            Label(text="CSV viewer", font_size=24, bold=True)
            SmartButton(text="Open a CSV", tone="cyan", on_click=open_csv)
            SmartButton(text=f"{MANY_ROWS} rows", on_click=show_many_rows)
        view["file"] = Label(text="A sample: some cities", font_size=14, text_color=TEXT_SOFT)
        view["holder"] = Box(width=TABLE_WIDTH, height=TABLE_HEIGHT, color="transparent")
        view["detail"] = Label(text="Click a row.", font_size=15)
    show_rows(SAMPLE)
</code></pre>
<ul>
<li><code>with VGroup(...)</code> opens a group: the objects made inside the block go one under the other, 14 px apart, 30 px from the edges.</li>
<li>The <code>HGroup</code> puts the title and the two buttons side by side. <code>hug=True</code> makes it only as large as its content.</li>
<li><code>SmartButton</code> is a button of the kit; <code>tone="cyan"</code> marks the main action. <code>on_click</code> takes a plain Python function.</li>
<li>The <code>Box</code> holds the place of the table, so a new table always goes to the same place, above the last line.</li>
</ul>
<p>No object has an x or a y: the groups place them.</p>
<h2>Step 4: a table from a list of dicts</h2>
<pre><code class="language-python">def show_rows(records):
    """A new table for the rows (a new file has other columns)."""
    if "table" in view:
        view["table"].remove()
    names = list(records[0].keys()) if records else []
    columns = [{"key": name, "title": name, "width": COLUMN_WIDTH} for name in names]
    with view["holder"]:
        view["table"] = SmartTable(columns=columns, rows=records, width="100%", height="100%", on_select=show_row)
</code></pre>
<p>A new file has other columns, so this makes a new table each time; <code>remove()</code> takes the old one away. The columns come from the keys of the first row. <code>with view["holder"]:</code> makes the table inside the box, and <code>"100%"</code> makes it fill it. <code>on_select=show_row</code> runs when a row is chosen.</p>
<p><code>SmartTable</code> makes only the rows that are seen. It has a filter box and sorting on its titles, with no code of yours. It starts sorted by its first column: that is why Ankara comes before İstanbul in the picture.</p>
<p>The table shows its values as text, so format numbers in Python (<code>f"{price:,.2f}"</code>).</p>
<h2>Step 5: the file dialog and the csv module</h2>
<pre><code class="language-python">def open_csv():
    path = open_file(file_types=("CSV files (*.csv)", "All files (*.*)"))
    if not path:
        return
    try:
        with open(path, newline="", encoding="utf-8-sig") as file:
            records = list(csv.DictReader(file))
    except (OSError, UnicodeDecodeError, csv.Error) as error:
        Toast.error(str(error), title="Could not read it")
        return
    view["file"].text = path
    show_rows(records)
</code></pre>
<p><code>open_file()</code> shows the open dialog of macOS or Windows. It returns the path of the chosen file, or <code>None</code> when the user cancels. It is the dialog of the computer, so the path is real: plain <code>open()</code> reads it.</p>
<p>The rest is the standard library. <code>newline=""</code> is what the <code>csv</code> module asks for, and <code>utf-8-sig</code> also reads a file that starts with the BOM mark that Excel writes. <code>csv.DictReader</code> gives one dict per line, keyed by the header line: the shape <code>show_rows</code> takes.</p>
<p>When reading fails (the file is gone, another encoding, a broken line), <code>Toast.error</code> shows a short message in a corner, and the old table stays.</p>
<h2>Step 6: a click on a row</h2>
<pre><code class="language-python">def show_row(table, row):
    view["detail"].text = "   ".join(f"{key}: {value}" for key, value in row.items())
</code></pre>
<p><code>on_select</code> calls this with the table and the row (a click, or Enter on a row). The row is the dict you gave. Setting <code>.text</code> changes the screen: there is no refresh call.</p>
<h2>Step 7: 100,000 rows</h2>
<pre><code class="language-python">def show_many_rows():
    view["file"].text = f"{MANY_ROWS} rows made in Python"
    show_rows([{"number": index, "square": index * index, "half": index / 2} for index in range(MANY_ROWS)])
</code></pre>
<p>The same <code>show_rows</code> shows 100,000 dicts. On my Mac they reach the table in about 2 seconds, and then it stays fast, because only the rows that are seen are made.</p>
<h2>Run it</h2>
<p>Save it as <code>csv_viewer.py</code> and run <code>python csv_viewer.py</code>. The tests of the repository open every example, this one too, in its real window on macOS and Windows.</p>
<h2>The whole program</h2>
<pre><code class="language-python"># Bismillah
"""A CSV file in a table: open one (a sample is shown first), filter it, click a row to see it. A SmartTable makes only
the rows that are seen: "100000 rows" shows that a big file stays fast."""

import csv

from ozdenui import App, Box, HGroup, Label, SmartButton, SmartTable, Toast, VGroup, open_file

PAGE_COLOR = "#F4F5F7"
TEXT_SOFT = "#5A6270"
TABLE_WIDTH = 820
TABLE_HEIGHT = 400
COLUMN_WIDTH = 170
MANY_ROWS = 100000

SAMPLE = [
    {"city": "İstanbul", "country": "Türkiye", "people": "15,655,924"},
    {"city": "Ankara", "country": "Türkiye", "people": "5,803,482"},
    {"city": "Berlin", "country": "Germany", "people": "3,878,100"},
    {"city": "Madrid", "country": "Spain", "people": "3,332,035"},
    {"city": "Rome", "country": "Italy", "people": "2,748,109"},
    {"city": "Paris", "country": "France", "people": "2,102,650"},
    {"city": "Vienna", "country": "Austria", "people": "2,005,760"},
    {"city": "Lisbon", "country": "Portugal", "people": "567,131"},
]

view = {}


def start(page):
    page.color = PAGE_COLOR
    with VGroup(gap=14, padding=30, align="left top"):
        with HGroup(hug=True, gap=14, align="left center"):
            Label(text="CSV viewer", font_size=24, bold=True)
            SmartButton(text="Open a CSV", tone="cyan", on_click=open_csv)
            SmartButton(text=f"{MANY_ROWS} rows", on_click=show_many_rows)
        view["file"] = Label(text="A sample: some cities", font_size=14, text_color=TEXT_SOFT)
        view["holder"] = Box(width=TABLE_WIDTH, height=TABLE_HEIGHT, color="transparent")
        view["detail"] = Label(text="Click a row.", font_size=15)
    show_rows(SAMPLE)


def show_rows(records):
    """A new table for the rows (a new file has other columns)."""
    if "table" in view:
        view["table"].remove()
    names = list(records[0].keys()) if records else []
    columns = [{"key": name, "title": name, "width": COLUMN_WIDTH} for name in names]
    with view["holder"]:
        view["table"] = SmartTable(columns=columns, rows=records, width="100%", height="100%", on_select=show_row)


def show_row(table, row):
    view["detail"].text = "   ".join(f"{key}: {value}" for key, value in row.items())


def show_many_rows():
    view["file"].text = f"{MANY_ROWS} rows made in Python"
    show_rows([{"number": index, "square": index * index, "half": index / 2} for index in range(MANY_ROWS)])


def open_csv():
    path = open_file(file_types=("CSV files (*.csv)", "All files (*.*)"))
    if not path:
        return
    try:
        with open(path, newline="", encoding="utf-8-sig") as file:
            records = list(csv.DictReader(file))
    except (OSError, UnicodeDecodeError, csv.Error) as error:
        Toast.error(str(error), title="Could not read it")
        return
    view["file"].text = path
    show_rows(records)


if __name__ == "__main__":
    App(start, title="CSV viewer", size=(900, 640)).run()
</code></pre>
<h2>When Tkinter is still the better choice</h2>
<ul>
<li>Tkinter comes with Python: nothing to install, which matters on a locked computer or in a classroom.</li>
<li>It runs on Linux. OzdenUI is not tested there yet: it would need the GTK or Qt web view of pywebview.</li>
<li>It has decades of answers on the web. OzdenUI is new.</li>
<li>One app file with PyInstaller: the handbook says it needs <code>--collect-data ozdenui</code>, but I have not tried it yet.</li>
</ul>
<p>If one of these matters to you today, Tkinter (or CustomTkinter, a modern skin on it) is the safer pick. If you are on macOS or Windows and want ready tables, dialogs and charts in plain Python, try OzdenUI on a small tool first.</p>
<h2>What to try next</h2>
<ul>
<li><strong>The handbook:</strong> ten short chapters for people who know Python and have never written a web page, in English (<a href="https://bug7a.github.io/ozdenui-python/handbook/">https://bug7a.github.io/ozdenui-python/handbook/</a>) and in Turkish (<a href="https://bug7a.github.io/ozdenui-python/handbook/?lang=tr">https://bug7a.github.io/ozdenui-python/handbook/?lang=tr</a>).</li>
<li><strong>The other examples</strong> in <code>examples/</code>: <code>file_tool</code> (a file dialog, a background job and a progress bar), <code>files</code> (a tree and dropped files with their paths), <code>charts</code>, <code>json_viewer</code>, <code>markdown_editor</code> and <code>todo</code>.</li>
<li><strong>A dark window</strong> is one word: <code>App(start, theme="dark")</code>.</li>
</ul>
<p>The repository: <a href="https://github.com/bug7a/ozdenui-python">https://github.com/bug7a/ozdenui-python</a></p>
<p>The site: <a href="https://bug7a.github.io/ozdenui-python/">https://bug7a.github.io/ozdenui-python/</a></p>
<p>If you try it, I would like to hear what was hard or missing.</p>
<hr />
<p><em>Written by me, the author of OzdenUI, with the help of Claude Code.</em></p>
]]></content:encoded></item></channel></rss>